Skip to content
Merged
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
10 changes: 9 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,16 @@ def clear_lru_cache():

@pytest.fixture(autouse=True)
def refuse_to_run_test_from_wrongly_named_files(request):
dirname: str = request.node.fspath.dirname
filename: str = request.node.fspath.basename
if not request.node.fspath.basename.startswith("test_"):
is_system_test: bool = "tests/system/" in dirname
if is_system_test and not request.node.fspath.basename.startswith("example_"):
raise Exception(
f"All test method files in tests/system must start with 'example_'. Seems that {filename} "
f"contains {request.function} that looks like a test case. Please rename the file to "
f"follow the example_* pattern if you want to run the tests in it."
)
if not is_system_test and not request.node.fspath.basename.startswith("test_"):
raise Exception(
f"All test method files in tests/ must start with 'test_'. Seems that {filename} "
f"contains {request.function} that looks like a test case. Please rename the file to "
Expand Down