Skip to content

pytest --pdb breaks Django test cases #1977

Closed
@adamchainz

Description

@adamchainz

Since #1890, when running with --pdb, Django test cases don't get per-test transactions. This is similar to #1932; Django has an equivalent _pre_setup function that needs calling per test to set up transactions (source - later in file for transaction support under TestCase). Since the --pdb change, the test case isn't called, so _pre_setup isn't called, so tests don't get transactional isolation.

A developer who always ran tests with --pdb noticed this first after our upgrade to 3.0.2. It took a long time to find that it was just the --pdb flag stopping database rollback, and not some weird behaviour in our app causing the inter-test failures 😢

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions