diff --git a/gittensor/classes.py b/gittensor/classes.py index ac40126d7..1c5001546 100644 --- a/gittensor/classes.py +++ b/gittensor/classes.py @@ -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 @@ -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) diff --git a/tests/test_classes.py b/tests/test_classes.py index a23e89f10..476036143 100644 --- a/tests/test_classes.py +++ b/tests/test_classes.py @@ -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,