Fixture scopes collide
A cheaper session-scoped fixture being requested by a short-lived function-scoped one, which pytest refuses to wire. The usual cause is a dependency added without reviewing the scope tree.
Scopes aligned, dependencies honest
Testing Python with pytest?
pytest handles small projects almost automatically and then needs real care once the suite grows: fixture scopes that quietly leak between tests, asyncio event loops that collide with other event loops, and a CI run that takes twenty minutes because the fast tests wait for the slow ones. We trace it through conftest.py, the fixture tree and the collection graph until the suite is honest about what it tests and quick about proving it.
What it is
pytest is the de facto testing framework for Python. It was created by Holger Krekel in 2003 (originally as py.test inside the py library), spun out into its own project, and now powers the test suites of most Python codebases in the wild. The current line is pytest 8.x, released in 2024 and maintained actively through 2025 and into 2026.
The framework is open source under the MIT license. Its core distinguishing features are a plain assert statement that still produces rich introspection, a fixture system with scopes (function, class, module, package, session), parametrization at test and fixture level, and a large plugin ecosystem covering coverage, parallelism, asyncio, Django, FastAPI, mocking, and property-based testing via Hypothesis.
The honest version
No technology is all upside. This is where pytest earns its place and where it tends to cause trouble.
Sound familiar?
The pytest problems that bring people to us, and what you have once each one is fixed.
A cheaper session-scoped fixture being requested by a short-lived function-scoped one, which pytest refuses to wire. The usual cause is a dependency added without reviewing the scope tree.
Scopes aligned, dependencies honest
A pytest-asyncio version change that redefined the event_loop fixture, or a test that mixes synchronous and asynchronous clients against the same loop.
asyncio tests running against one loop
SQLite under xdist workers, or a session-scoped Postgres database with no isolation between tests. Transactions-per-test fixtures or a per-worker database both solve it; neither is free.
Parallel runs isolated at the database
A test that writes to a shared file, binds to a fixed port, or mutates a module-level global. The worker crashes, xdist retries, and the first symptom is a flaky test the authors cannot reproduce locally.
Shared resources scoped per worker
A fixture defined in the wrong conftest.py, a missing __init__.py breaking the package graph, or a rootdir that pytest resolved differently from what the project expects.
conftest layout matching the import tree
A missing editable install, a sys.path that works locally and not on CI, or a circular import between test helpers and application code.
Imports work from a clean checkout
An async function being called without await, returning a coroutine object that then gets asserted against as if it were the real result.
Awaits restored, async tests honest
Collection overhead from heavy imports in conftest.py, autouse fixtures doing unnecessary setup, and an xdist configuration that is not actually parallelizing the slow tests.
Runtime cut while coverage holds
What we do
Call us for a single failing fixture, or let us take on the whole pytest estate.
How it works
Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.
We fix the cause, not the symptom. If something is down, getting it back up comes first.
Backups, monitoring, updates and access, so the same problem can't quietly come back.
You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.
Often found together
We work on the whole stack, so the problem can be wherever it actually is.
Most of the time it is one of four things: a test that depends on wall clock or time zone, a shared database or port that only collides under xdist, a Python version difference between developer machines and CI, or an environment variable that is set in a developer shell and not in the CI container. We reproduce the failure on CI first, then fix the cause instead of adding retries.
Pin pytest-asyncio to a specific major, choose either asyncio_mode=auto or strict and stick with it, and avoid creating your own event loops inside tests. If you need a shared loop for a client and a database connection, express that through the fixture tree rather than through global state.
A fixture scoped higher than its data lifetime, an autouse fixture that mutates module state, or a yield fixture whose teardown branch never actually runs because of an exception. We walk the scopes, make the mutations explicit, and either lower the scope or add proper teardown.
Yes, and pytest-django makes the migration straightforward. Most unittest TestCase classes continue to work, which lets you adopt pytest incrementally rather than rewriting hundreds of files. Fixtures and parametrization are where the real value shows up.
First, measure. pytest --durations tells you which tests are actually slow, and they are usually fewer than the team thinks. From there, options include parallelizing with xdist, caching fixtures sensibly, moving integration tests to a separate stage, and killing autouse fixtures that run on every test for no good reason.
The estimate is on us. Share the failing output, the plugin list and the suite size, and a priced scope is in your inbox before any changes happen.
Free estimate
Send the failing test, the conftest layout and the plugin versions. A human writes back with a quote, and work only begins once you agree.
Your message is with a real person, and we'll get back to you soon.
Rather talk now? Call us: