What is pytest?
pytest is a popular Python testing framework designed to make writing and running tests simple, scalable, and expressive. It allows developers to create small, readable test functions using plain Python syntax, without requiring boilerplate code or complex setup. Pytest automatically discovers tests, provides detailed failure output, and supports powerful features like fixtures (for reusable test setup), parameterization (to test multiple inputs easily), and plugins for extended functionality. It is widely used in both small projects and large production systems because it helps ensure code reliability while keeping tests clean and easy to maintain.
When testing your function using Pytest, you might want to print only failed tests instead of both failed and successful tests. If so, add --lf to pytest. “lf” stands for “list fails”.
If you are not aware of Pytest, it is the framework that makes it easy to write small tests in Python. You can find more about Pytest from my article Pytest for Data Scientists: A Comprehensive Guide to Pytest for your Data Science Projects.
Conclusion
Filtering pytest output to show only failed tests keeps your feedback loop tight, especially as your test suite grows. Instead of scrolling through hundreds of passing tests, you can focus immediately on what needs fixing.
Read Next
Want a full CI/CD testing workflow? Read our deep dive: Build Reliable Machine Learning Pipelines with Continuous Integration. Automate your tests from local to production.




