Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data migrations: preserve data between fixture tests #1028

Open
frague59 opened this issue Sep 22, 2022 · 0 comments
Open

Data migrations: preserve data between fixture tests #1028

frague59 opened this issue Sep 22, 2022 · 0 comments

Comments

@frague59
Copy link

Hi,

I'm working on a app with default data migrations (some models are populated with the RunPython migration method, ie. default users, related models for select...).

I'm working on a test with data sets declares in a list of dicts, using a fixture with the request.param magic.

My fixture data looks like:

FIXTURE_DATA = [{"name": "Foo"}, {"name": "Bar"}...]

@pytest.fixture(scope="session", params=FIXTURE_DATA)
def data(request)
    return request.param

@pytest.mark.django_db
def test_01_data(data):
    # Make the stuff...
    pass

Then I try to run the test, with a single fixture yielding my test data, the whole content of the database is freed between each fixture run:

  • First data dict instance: OK
  • Second data dict instance: The database structure is in place, but RunPython migrated data are flushed... my test cannot continue.

I'm using a "droppable" sqlite file in /dev/shm, I'ld like to explore the content of the database after the tests - is it possible ?

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant