Skip to content

chore: switch pytest to importlib import mode for monorepo#50

Merged
hweej merged 1 commit intomainfrom
chore/pytest-importlib-mode
Apr 23, 2026
Merged

chore: switch pytest to importlib import mode for monorepo#50
hweej merged 1 commit intomainfrom
chore/pytest-importlib-mode

Conversation

@hweej
Copy link
Copy Markdown
Contributor

@hweej hweej commented Apr 23, 2026

Summary

Switch pytest to --import-mode=importlib so uv run pytest (and ptw) work from the monorepo root without test module name collisions.

  • Add pytest config at root pyproject.toml
  • Move cell2zarr test helpers from conftest.py to src/cell2zarr/_testing.py (conftest should only contain fixtures, not importable helpers)
  • Remove unneeded tests/__init__.py files (importlib mode doesn't need them)

pytest officially recommends importlib mode for new/modern projects — see https://docs.pytest.org/en/stable/explanation/pythonpath.html#which-import-mode

Test plan

  • uv run pytest from root → 181 tests pass
  • make test → 84 tests pass (api)
  • make test-cell2zarr → 69 tests pass

- Add --import-mode=importlib to root pytest config
- Move cell2zarr test helpers from conftest.py to src/cell2zarr/_testing.py
- Remove tests/__init__.py files (not needed with importlib mode)

This allows uv run pytest (and pytest-watcher) to work from the monorepo root
without test module name collisions across packages. pytest recommends importlib
mode for new projects.
@hweej hweej added the refactoring Code refactoring label Apr 23, 2026
@hweej hweej self-assigned this Apr 23, 2026
@hweej hweej added the refactoring Code refactoring label Apr 23, 2026
@hweej hweej merged commit 09518b2 into main Apr 23, 2026
3 checks passed
@hweej hweej deleted the chore/pytest-importlib-mode branch April 23, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant