You join a team whose Python automation repo has no tests. Where do you start?
BeginnerScenarioTesting, CI/CD, packaging & services
Answer
Situation read → Untested code that touches infrastructure.
What I'd do →
- Add pytest, ruff and mypy to CI first, even with few tests, so the bar can only go up.
- Write tests for the most destructive scripts first (cleanup, deletion), using moto and dry-run assertions.
- Add a test with every bug fix that reproduces the bug.
- Refactor big scripts into pure functions as you touch them.
Why → Risk-first testing gives the most protection per hour.
Interview tip → "Test the scripts that delete things first."
More on Testing, CI/CD, packaging & services
Your pytest suite takes 12 minutes. How do you speed it up?IntermediateA test passes locally but fails in CI only when run with the rest of the suite. What do you suspect?IntermediateYou want a reusable CI pipeline for 15 Python tool repos. What goes in it?IntermediateYour Python Docker image is 1.1 GB. How do you shrink it?IntermediateYou want to distribute an internal CLI to 200 engineers. What are your options?IntermediateA Flask app runs with `app.run()` in production and falls over under load. What do you change?Beginner