pytest-rulebearing
Each Rulebearing architecture rule as a test in the pytest run: one item per rule, failing with the rule's fix and its first violations. Source, documentation and releases: https://github.com/benbahrenburg/rulebearing
pip install pytest-rulebearing # installs the rulebearing wheel for this platform too
pytest --rulebearing # or set rulebearing = true, below
[tool.pytest.ini_options]
rulebearing = true
rulebearing_config = "rulebearing.yaml" # optional; the binary finds one by default
rulebearing_args = ["src"] # optional; what to cruise
What it does
When --rulebearing is passed or rulebearing = true is set, the plugin runs rulebearing cruise --output-type json once, during collection, and adds one item per rule, named rulebearing::<rule> and marked rulebearing (so -m rulebearing and -k select them). It never evaluates a rule: the binary decides, the plugin reports (ADR-0010 rule 4).
The failure message is exactly the message the junit reporter writes for that rule (crates/rb-report/src/junit.rs, Wave 2 plan § 1.5):
| Rule outcome | Item | Message |
|---|---|---|
| error-severity violations | fails | the fix (or N violation(s) of <rule>), then the first five violations as id from -> to (line L, column C), then ... and N more |
| vacuous (ADR-0007) | fails | rule `<name>` is vacuous: its <side> side matched nothing, so it checks nothing (ADR-0007) |
| expired rule or known violation, a ratchet over its ceiling or without a budget | fails | the junit error or failure text |
| warn, info or known findings only | passes | the findings in a rulebearing report section |
| no violation | passes |
A run that writes no result (the binary is missing, or the configuration is invalid) is one failing item, rulebearing::cruise, whose message is the command, its exit code and its stderr.
| Option | Ini key | Meaning |
|---|---|---|
--rulebearing |
rulebearing |
turn the plugin on |
--rulebearing-config FILE |
rulebearing_config |
--config |
--rulebearing-graph FILE |
rulebearing_graph |
--graph: read a graph document instead of extracting |
--rulebearing-binary FILE |
rulebearing_binary |
the binary; default RULEBEARING_BINARY, then the one the rulebearing wheel carries |
--rulebearing-arg ARG (repeatable) |
rulebearing_args |
further arguments, such as directories to cruise |
Paths on the command line are relative to the invocation directory; paths in the ini file are relative to the ini file, which is also where the binary runs.
Developing
The plugin is linted and type-checked by the root configuration through cargo xtask lint (ADR-0023) and holds the 70% line floor of ADR-0018. The tests run against the shared fixture adapters/fixture with the binary built from the checkout; tests/test_junit_equality.py is the proof that every message equals rulebearing cruise -T junit's.
cargo build --release -p rb-cli
pip install pytest pytest-cov hatchling packaging
pytest adapters/python --cov=adapters/python # from the repository root
Plan: Wave 2, Step 14. Release: docs/release.md.
Metadata
Release files for pytest-rulebearing 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_rulebearing-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for pytest_rulebearing-0.1.3-py3-none-any.whl |
Release files / pytest_rulebearing-0.1.3-py3-none-any.whl
| Download URL | pytest_rulebearing-0.1.3-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6434426ed1e4066440e2941b6cb989c61614080626d56ddcce9d8f7016ce03a4
|
|
BLAKE2b-256 checksum How to use checksums |
8518375c28d7c8ec1fa28f14f3ebd33f56c0ebfccf99baeaa27170755552a18c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Security for pytest-rulebearing 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.