Skip to content

--reuse-db and --create-db not working together #411

Closed
@ryankask

Description

@ryankask

I noticed the below issue when using the workflow presented here: https://pytest-django.readthedocs.io/en/latest/database.html#example-work-flow-with-reuse-db-and-create-db. It seems like the behaviour changed in a recent version although it's possible I never noticed this occurred.

When I run the tests passing the --create-db flag, the database is recreated and the migrations are run (notice the time). The database, however, is dropped despite the --reuse-db flag being passed via addopts.

$ pytest tests/app --create-db
...............................................................................................................................
127 passed in 8.23 seconds

When I next run the tests without the --create-db flag the database is again recreated and the migrations are run because it was previously dropped.

$ pytest tests/app
...............................................................................................................................
127 passed in 7.01 seconds

If I run the tests a third time exactly as above, the database is properly reused:

$ pytest tests/app
...............................................................................................................................
127 passed in 1.12 seconds

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