In July a customer was given two discounts on one order that our rules say can never be combined. Fixing the code took ten minutes. What took the afternoon was finding that the test for exactly that case already existed, had been written in February, and was failing.
Our pricing package had been rebuilt that spring by a contractor team, who named their test files after the modules they covered: discount_tests.py, basket_tests.py, tax_tests.py. Our pipeline runs pytest from the repository root and lets it discover the tests. pytest only collects files whose names match its python_files setting, which by default is test_*.py and *_test.py. A plural tests matches neither. The files sat in the tests directory, imported cleanly, and were never opened.
The authors had not been careless. They ran their tests the way most of us run the tests we are working on, by passing the file path to pytest, and pytest collects any file named on the command line whatever it is called.…