Python · testing
zero-assertion-test
python:zero-assertion-test Test contains no assertion of any kind — it passes as long as nothing raises.
- Code
- SARJ043
- Default
- error
- Fix
- none
- Languages
- python
Why
Calling production code without verifying an outcome gives the test no observable behavioral contract.
Fix
Assert the result or use an explicit pytest expectation such as `pytest.raises` or `pytest.warns`.
Before / after
Executed by this rule’s unit tests.
Before
Test verifies no outcome
def test_conditions():
evaluate_conditions(record, conditions)
After
Test verifies the result
def test_conditions():
assert evaluate_conditions(record, conditions)
Limits
- Only pytest-collected test functions in test paths are analyzed.
- Skipped, xfailed, benchmark, placeholder, helper-delegating, and explicit expectation tests are excluded.