# pytest-django reusedb option applied for several fixtures

**URL:** https://forum.djangoproject.com/t/pytest-django-reusedb-option-applied-for-several-fixtures/16046
**Category:** Using Django
**Created:** [September 19, 2022, 1:15am UTC](https://forum.djangoproject.com/t/pytest-django-reusedb-option-applied-for-several-fixtures/16046 "2022-09-19T01:15:21Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![atcrank](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/atcrank/32/2029_2.png) [@atcrank](https://forum.djangoproject.com/u/atcrank)
#### Post date: [September 19, 2022, 1:15am UTC](https://forum.djangoproject.com/t/pytest-django-reusedb-option-applied-for-several-fixtures/16046/1 "2022-09-19T01:15:21Z")

</div>

Hi all,

Today I am working with importing data files with a script that should add data if it is missing, or update it if there is a match on a unique field (e.g. username) or unique\_together fields (e.g. contenttype). I have been able to create a pytest database fixture set in conftest.py like this:

```auto
@pytest.fixture
def empty_db(django_db_setup):
    pass

@pytest.fixture
def full_db(django_db_setup, django_db_blocker):
    with django_db_blocker.unblock():
         load_json_into_fresh_database("tests/test_fixtures/db_dev.json")

@pytest.fixture
def db_conditions():
    """Mapping of possible database conditions as fixtures"""
    return {1: empty_db, 2: full_db}

@pytest.fixture(params=[1,2])
def db_condition(request, db_conditions):
    return db_conditions[request.param]

```

I would like the --reusedb option to keep both conditions of the db fixture in memory, instead of taking a minute or two per test to recreate the ‘full\_db’ fixture. A few versions ago, I was just using a full fixture, and calling that the db.
