A parcel tool accepts lengths up to and including 100 centimeters. A test with only an 80-centimeter parcel still passes if someone accidentally changes the inclusive comparison to a strict one. Test 99, 100, and 101 centimeters in one function. Give the boundary case an ID you can use to recognize it in the test output.
import pytest
@pytest.mark.parametrize("length,accepted", [
pytest.param(99, True, id="under-limit"),
pytest.param(100, True, id="at-limit"),
pytest.param(101, False, id="over-limit"),
])
def test_package_length(length, accepted):
assert accepts_length(length) is accepted
Import accepts_length from your application before running the test. pytest -q should run each case. If you temporarily change the product comparison from inclusive to strict in a disposable checkout, the ID at-limit should be visible in the failure. Restore the comparison and confirm all three cases pass.
Keep expected outcomes in the parameters. Writing length <= 100 as the expected value would repeat the rule in code and make the intent harder to read at the failing example. If the product supports fractional centimeters, add a fractional case explicitly with the precision the product actually uses.
Run the boundary case by ID when a comparison changes
With the example saved in test_parcel.py, use the collected ID to isolate the inclusive edge.
pytest -q 'test_parcel.py::test_package_length[at-limit]'
If the exact limit fails but the under-limit case passes, inspect the inclusive comparison first. If both 100 and 101 pass, check whether the validation uses the intended unit or threshold. Run the full parameterized test after each focused change to confirm the three neighboring values behave together. For decimal input, test the smallest increment the product accepts on each side of 100.
