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
7 changes: 7 additions & 0 deletions oida/checkers/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,15 @@ def _check_if_service_or_selector(self) -> bool:
if self.name in ("services", "selectors"):
return True

# Don't require for test files
if self.name.startswith("test_"):
return False

# Check if file is in services/ or selectors/ directory
if self.module:
# Don't require for test modules
if ".tests." in self.module or ".test." in self.module:
return False
# Check if module contains .services. or .selectors., or ends with .services or .selectors
if ".services." in self.module or ".selectors." in self.module:
return True
Expand Down
28 changes: 28 additions & 0 deletions tests/test_keyword_only_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,31 @@ def test_top_level_method_checked_nested_not_checked(
) -> None:
# Top-level class method is valid, nested class method is not checked
assert not violations


@pytest.mark.module(
"""\
def test_create_user(username, email):
pass
""",
name="test_user_services",
module="project.app.tests.services",
)
def test_test_files_not_checked(
checker: KeywordOnlyChecker, violations: list[Violation]
) -> None:
assert not violations


@pytest.mark.module(
"""\
def util(username, email):
pass
""",
name="utils",
module="project.app.tests.services",
)
def test_test_dirs_not_checked(
checker: KeywordOnlyChecker, violations: list[Violation]
) -> None:
assert not violations