The suite is green. You run it with -p no:randomly off, or add a test in the middle, and two unrelated tests turn red.
@pytest.fixture(scope="module")
def config():
return {"retries": 3, "debug": False}
def test_debug_mode(config):
A module-scoped fixture returning a mutable object is shared, not copied. Your tests pass in order and fail when you shuffle them.
The suite is green. You run it with -p no:randomly off, or add a test in the middle, and two unrelated tests turn red.
@pytest.fixture(scope="module")
def config():
return {"retries": 3, "debug": False}
def test_debug_mode(config):

As I've been onboarding to my new position, I've been reviewing some of my coworker's code. I learned...

Mastering Pytest Fixtures Fixtures are the backbone of pytest testing. They set up objects...

An agent patch can pass every fixture in your repository and still be wrong. The fixtures are part of...

Testing at the right level with pytest, covering the unhappy path with parametrize and fixtures, avoiding over-mocking with…

An agent patch is a hypothesis. A test suite is the only evidence a reviewer gets. Most suites fail...

Our test suite kept flaking from cross-file state leakage. xdist's persistent workers were the cause, not the cure. Here's the…