pytestarch is a Python test framework that enables static analysis of software architecture by defining and enforcing rules based on import dependencies between modules. It integrates seamlessly with pytest to ensure architectural constraints are met. The current version is 4.0.1, with major releases occurring periodically to introduce new features and adapt to Python version changes.
pip install pytestarchVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define and verify architectural layer dependencies using `pytestarch`. It assumes a standard Python project layout with a `src/` directory containing your modules and a `tests/` directory for your `pytestarch` test files. The `PYTEST_ARCH_ROOT` environment variable is crucial for module discovery.
Review the official documentation for updated module export paths and adapt any direct imports or custom extensions as necessary.
Upgrade your Python environment to version 3.9 or newer to ensure compatibility.
Ensure `PYTEST_ARCH_ROOT` is set (e.g., `PYTEST_ARCH_ROOT=./src pytest`) to the absolute or correct relative path of your main source directory. Additionally, verify that the `root_path` argument passed to `get_layers` aligns with how your modules are imported (e.g., 'src' if your imports are `from src.module ...`).
Ensure your `Layer` definitions comprehensively cover all expected modules. If encountering `KeyError`, consider upgrading to v4.0.1+ and, if the issue persists, use more explicit module paths rather than overly broad regexes if necessary.
No dependency data recorded yet.