pytest-dev / pytest-dev/pytest-django

How to persisit data inside the database after tests run

Open
#1,025 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
367
PR merge metrics
No merged PRs in 30d

Description

Is there any way to persist data inside a (postgres) database after the tests run.

I've run through https://pytest-django.readthedocs.io/en/latest/database.html several times and none of the solutions provided seem to help.

Marking this test with @pytest.mark.django_db doesn't help, using the django_db_blocker fixture and calling .unblock() as the first line of the test doesn't work, the --reuse-db flag => in the database not being deleted but it remains empty once the tests run.

I see no object while the tests are running, so it seems to me like transactions aren't be committed, but I can't figure out how to change that.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file or failing test is named. Start by reproducing the behavior with the django_db marker, django_db_blocker fixture, and --reuse-db flag, then trace the database setup and transaction handling; done would require a maintainer-confirmed explanation and a documented fix or regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, postgresql, python
Domain
databases, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.