Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gittensor/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def is_test_file(self) -> bool:
r'(^|/)androidtest[a-z]*/',
r'(^|/)integrationtest/',
r'(^|/)spec/',
r'\.tests?/', # .NET MyProject.Tests/FooTests.cs
]
if any(re.search(pattern, filename_lower) for pattern in test_dir_patterns):
return True
Expand All @@ -98,6 +99,7 @@ def is_test_file(self) -> bool:
r'\.spec\.[^.]+$',
r'^test\.[^.]+$',
r'^tests\.[^.]+$',
r'^conftest\.py$',
]

return any(re.search(pattern, basename) for pattern in test_patterns)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ def test_is_test_file_preserves_existing_test_conventions():
assert _file_change('src/foo/bar.py').is_test_file() is False


@pytest.mark.parametrize(
'filename',
[
'src/MyProject.Tests/AccountServiceTests.cs',
'src/MyProject.Tests/AccountServiceTest.cs',
],
)
def test_is_test_file_detects_dotnet_dotted_tests_directory(filename):
assert _file_change(filename).is_test_file() is True


@pytest.mark.parametrize(
'filename',
[
'conftest.py',
'tests/conftest.py',
'project/conftest.py',
'project/sub/package/conftest.py',
],
)
def test_is_test_file_detects_conftest_at_any_depth(filename):
assert _file_change(filename).is_test_file() is True


def test_pull_request_handles_deleted_label_event():
pr_data = {
'number': 42,
Expand Down
Loading