Install & Compatibility
Where this runs
tested against v0.0.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.094s · 31MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.7s · import 0.078s · 31MB
29MB installed
● package 29MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
archrule
✓ from pytest_archon import archrule
✗ from pytest_archon.archrule import archrule
The correct import is from the top-level module, not a submodule.
ArchRule
✓ from pytest_archon import archrule
A class ArchRule is not directly importable; use the archrule function.
Define an architecture rule that prevents the 'services' package from importing 'ui' or 'db' packages in the 'myapp' project.
import pytest
from pytest_archon import archrule
def test_import_rule():
(
archrule("myapp.services")
.should_not_import("myapp.ui")
.should_not_import("myapp.db")
.check("myapp")
)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pytest_archon'
pytest-archon is not installed or not installed in the current virtual environment.
fixRun 'pip install pytest-archon' to install the package.
TypeError: archrule() missing 1 required positional argument: 'package'
The archrule function requires the package name as the first argument.
fixUse archrule('myapp.services') with a string argument. AttributeError: 'ArchRule' object has no attribute 'should_not_import'
The import is wrong: you imported ArchRule directly, but the correct usage is calling the archrule function.
fixUse 'from pytest_archon import archrule' and then call archrule() to get the rule builder.
Upgrade
Version history
0.0.7latest on PyPI · released Sep 19, 2025
Audit
Dependencies
pytestrequiredRequired: pytest-archon is a pytest plugin and runs within pytest.