Batu Lab NotesPractical developer guides

Make a local CLI’s supported file-name conventions visible

By Batu · English technical notes

Also published in our Blogger archive.

Direct answer

A CLI should publish exact filename conventions instead of implying that it understands every test framework. The predicate supports two Python patterns: test_*.py and *_test.py. The unsupported testing_api.py case matters because it looks related to a reader but does not match either documented rule.

This is a naming decision, not a test-discovery implementation. The checks do not recurse into directories, import modules, or inspect framework configuration. The assertions make the boundary executable, so adding a new convention requires a deliberate change to both behavior and documentation.

Suffix handling is also explicit: test_api.txt does not qualify. If a project uses another language or a framework-specific convention, expose it as a separate pattern rather than letting an opaque heuristic decide.

Complete example

from pathlib import Path


def supported(name: str) -> bool:
    path = Path(name)
    return path.name.startswith("test_") and path.suffix == ".py" or path.name.endswith("_test.py")

assert supported("test_api.py")
assert supported("api_test.py")
assert not supported("testing_api.py")
print("supported=test_*.py,*_test.py")

Expected stdout:

supported=test_*.py,*_test.py

Sources

- pathlib documentation

Prepared with AI assistance. The example uses synthetic data; its stated limits apply.