Skip to content

Commit 2d10ce4

Browse files
author
tomcodegen
committed
skip
1 parent fd3a5a9 commit 2d10ce4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

conftest.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import logging
22
import os
3+
from pathlib import Path
4+
5+
import pytest
36

47
from codegen.sdk.testing.models import Size
58

@@ -74,3 +77,29 @@ def pytest_configure(config):
7477
filename=f"build/logs/tests_{worker_id}.log",
7578
level=config.getini("log_file_level"),
7679
)
80+
81+
82+
def is_git_lfs_pointer(file_path: Path) -> bool:
83+
"""Check if a file is a git LFS pointer file"""
84+
try:
85+
with open(file_path) as f:
86+
first_line = f.readline().strip()
87+
return first_line == "version https://git-lfs.github.com/spec/v1"
88+
except Exception:
89+
return False
90+
91+
92+
@pytest.fixture(autouse=True)
93+
def skip_lfs_tests(request):
94+
"""Skip tests that depend on git LFS files if they haven't been pulled"""
95+
# Get the test module path
96+
test_path = Path(request.module.__file__)
97+
98+
# Only run for integration tests
99+
if not str(test_path).startswith(str(Path.cwd() / "tests" / "integration")):
100+
return
101+
102+
# Get the expected diff path from the test's expected fixture
103+
expected = request.getfixturevalue("expected")
104+
if isinstance(expected, Path) and is_git_lfs_pointer(expected):
105+
pytest.skip(f"Test requires git LFS file {expected} which hasn't been pulled")

0 commit comments

Comments
 (0)