Summary
smpy create-module always names the generated test file tests/test_module.py. Since smpy new scaffolds a workspace whose members live under modules/*, the second module you create in a repo makes root-level pytest fail during collection:
ERROR collecting modules/geowiki_articles/tests/test_module.py
import file mismatch:
imported module 'test_module' has this __file__ attribute:
/…/modules/geowiki_apps/tests/test_module.py
which is not the same as the test file we want to collect:
/…/modules/geowiki_articles/tests/test_module.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
make test runs uv run pytest from the repo root, so this breaks the scaffolded quality gate — with 5 modules I got 4 collection errors and 0 tests run.
Cause
The tests/ directories have no __init__.py, so pytest's default prepend import mode derives the module name from the basename alone. Five files all named test_module collide.
Reproduction
smpy new demo --preset standard --yes --no-install
cd demo
smpy create-module alpha --dest modules/alpha
smpy create-module beta --dest modules/beta
uv sync --all-packages
uv run pytest # collection error
Suggested fix
Any one of these works; the first is the smallest change:
- Name the file after the module —
tests/test_{{PACKAGE_NAME}}.py instead of tests/test_module.py. Also reads better in output.
- Emit an empty
tests/__init__.py in the module template, making the test modules properly packaged and their names unique.
- Set
[tool.pytest.ini_options] importmode = "importlib" in the workspace template's pyproject.toml.
I went with (1) locally.
Environment
simple_module_cli 0.0.30, pytest 8.x, Python 3.14
Minor, but it hits every multi-module repo on the first make test, which is also the first thing the scaffold's README tells you to run.
Summary
smpy create-modulealways names the generated test filetests/test_module.py. Sincesmpy newscaffolds a workspace whose members live undermodules/*, the second module you create in a repo makes root-levelpytestfail during collection:make testrunsuv run pytestfrom the repo root, so this breaks the scaffolded quality gate — with 5 modules I got 4 collection errors and 0 tests run.Cause
The
tests/directories have no__init__.py, so pytest's defaultprependimport mode derives the module name from the basename alone. Five files all namedtest_modulecollide.Reproduction
Suggested fix
Any one of these works; the first is the smallest change:
tests/test_{{PACKAGE_NAME}}.pyinstead oftests/test_module.py. Also reads better in output.tests/__init__.pyin the module template, making the test modules properly packaged and their names unique.[tool.pytest.ini_options] importmode = "importlib"in the workspace template'spyproject.toml.I went with (1) locally.
Environment
simple_module_cli0.0.30, pytest 8.x, Python 3.14Minor, but it hits every multi-module repo on the first
make test, which is also the first thing the scaffold's README tells you to run.