PyTestArch
Test framework for software architecture based on imports between modules
Decision gist · record as of 2026-08-14
Yes. PyTestArch is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a real problem—catching architectural violations early. It's well-suited for teams that want to enforce module-level design constraints. The permissive Apache-2.0 license poses no barrier. Start with the basic rule DSL shown in the docs; optional visualization requires matplotlib.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later; matplotlib is optional but needed only if you want to visualize dependency graphs.
- Low friction install with a single runtime dependency (networkx).
- Active maintenance with recent commits and a stable release cadence; last release was 371 days ago and the repository remains actively developed.
License · maintenance · safety
Apache-2.0 (permissive) — Licensed under Apache-2.0 (permissive), so you can use it freely in commercial and private projects with minimal restrictions.
last release 2025-08-08 (371 days) · last repo commit 2026-08-10 · 170 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 219,634 downloads/mo, #9,323 on PyPI
Alternatives
Verify before relying
from pytestarch import get_evaluable_architecture, Rule
evaluable = get_evaluable_architecture("/path/to/project", "/path/to/project/src")
rule = Rule().modules_that().are_named("project.src.moduleB").should_not().be_imported_by_modules_that().are_sub_modules_of("project.src.moduleA")
rule.assert_applies(evaluable)- Whether the package handles large codebases efficiently or has known performance limits.
- Whether visualization output (with matplotlib) is publication-ready or primarily for debugging.
- How well the rule DSL scales for complex architectural policies across many modules.
What it is and what it does
PyTestArch is a testing framework that lets you codify architectural rules for Python projects and verify that your codebase respects them. It scans your source code to build a dependency graph, then lets you write rules declaratively (e.g., "module B should never be imported by module A") and assert those rules hold. It's inspired by ArchUnit and integrates naturally with pytest.
The package depends only on networkx for graph operations and optionally matplotlib for visualization. It supports Python 3.9 through 3.13 and has been actively maintained since its initial release in 2022, with a recent update in August 2025.
Use it for
- Enforce layered architecture by preventing lower layers from importing upper layers in a multi-tier application.
- Prevent circular dependencies between modules by defining rules that catch them during test runs.
- Document and validate that certain modules remain isolated (e.g., internal utilities not imported by external code).
- Catch accidental cross-team dependencies in large codebases by defining import policies per module group.
- Integrate architecture checks into CI/CD pipelines as part of your test suite alongside unit and integration tests.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
PyTestArch is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a real problem—catching architectural violations early. It's well-suited for teams that want to enforce module-level design constraints. The permissive Apache-2.0 license poses no barrier. Start with the basic rule DSL shown in the docs; optional visualization requires matplotlib.
Install
pytestarch on PyPI
Before you install
Low friction install with a single runtime dependency (networkx). Active maintenance with recent commits and a stable release cadence; last release was 371 days ago and the repository remains actively developed.
Requires Python 3.9 or later; matplotlib is optional but needed only if you want to visualize dependency graphs.
License in practice
Licensed under Apache-2.0 (permissive), so you can use it freely in commercial and private projects with minimal restrictions.
Quickstart
from pytestarch import get_evaluable_architecture, Rule
evaluable = get_evaluable_architecture("/path/to/project", "/path/to/project/src")
rule = Rule().modules_that().are_named("project.src.moduleB").should_not().be_imported_by_modules_that().are_sub_modules_of("project.src.moduleA")
rule.assert_applies(evaluable)
Verify before relying
- Whether the package handles large codebases efficiently or has known performance limits.
- Whether visualization output (with matplotlib) is publication-ready or primarily for debugging.
- How well the rule DSL scales for complex architectural policies across many modules.
Package facts
| License | Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagenetworkx |
| Maintenance | Actively maintained 371 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 219,634 / month, #9,323 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: TestingTopic :: Software Development :: Testing :: Unit |
Evidence: pytestarch-4.0.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “architecture testing framework”
- PyTestArchPyTestArch lets you define and test architectural rules for Python…
- dlt-metaDLT-META is a metadata-driven framework that automates bronze and…
- namekoNameko is a microservices framework for Python that lets you build…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also import-linter · pytest-archon · pytest-beartype-tests · pymarkdownlnt · tach · pytest-isort · plyara · pytest-black · j2lint