š Stop Testing Your Code and Ignoring Your Database (Catching N+1 in Pytest)
Your green CI pipeline might be lying to you. šØ It tells you the code works, but itās quietly hiding the N+1 database disaster that will bring down your production environment next week. As Python...

Source: DEV Community
Your green CI pipeline might be lying to you. šØ It tells you the code works, but itās quietly hiding the N+1 database disaster that will bring down your production environment next week. As Python & SQLAlchemy developers, we spend hours writing tests to assert our applicationās final state, but we treat the database layer like a complete black box. We test what the application does, but completely ignore how it does it. The business cost of this abstraction is expensive. šø Every inefficient query and silent lazy-load that slips into the main branch directly inflates your cloud bill and degrades the user experience. I got tired of this, so I built and open-sourced pytest-capquery. š ļø šÆ What it does pytest-capquery treats SQL queries as first-class citizens in your Pytest suite. By intercepting the SQLAlchemy engine at the driver level, it enforces a strict, chronological timeline of your execution footprint. Instead of just checking if a function returns True, you can rigorously