Discovery and assertions
pytest discovers test files and test functions by naming conventions such as test_rules.py and test_threshold. Plain assert expressions produce informative comparisons when they fail. Run the suite with the intended interpreter using python -m pytest. Passing tests establish only the behaviors actually exercised, not universal correctness. A test asserting classify(80)=="warning" directly checks the inclusive threshold contract; it should fail if the implementation accidentally changes from >=80 to >80 in the production function being exercised by that test. Contract-focused tests detect meaningful regressions and remain useful after internal refactoring, while interpreter-specific invocation helps ensure imports and dependencies come from the same environment as the application code under investigation today rather than an unrelated global installation. A test that repeats the exact implementation expression may preserve the same defect; derive expected outcomes from the stated behavior and select cases that would expose a plausible mistake rather than merely run the code without observing its result carefully.
A test asserting classify(80)=="warning" directly checks the inclusive threshold contract; it should fail if the implementation accidentally changes from >=80 to >80 in the production function being exercised by that test.
Contract-focused tests detect meaningful regressions and remain useful after internal refactoring, while interpreter-specific invocation helps ensure imports and dependencies come from the same environment as the application code under investigation today rather than an unrelated global installation.
A test that repeats the exact implementation expression may preserve the same defect; derive expected outcomes from the stated behavior and select cases that would expose a plausible mistake rather than merely run the code without observing its result carefully.