Closed
Description
Look like if we will use scope session in fuxture that using multi db fixture will not work.
Example:
@pytest.fixture(scope='session')
@pytest.mark.django_db(databases=['default', 'other_db')
def create_unmanaged_db_models():
#Make some db action
...
@pytest.mark.usefixtures('create_unmanaged_db_models')
@pytest.mark.django_db(databases=['default', settings.LEADGEN_DB])
def test_some_case():
...
Will raise follow exception
RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it.
But if we will delete scope session code will work fine.
Example:
@pytest.fixture()
@pytest.mark.django_db(databases=['default', 'other_db')
def create_unmanaged_db_models():
#Make some db action
...
@pytest.mark.usefixtures('create_unmanaged_db_models')
@pytest.mark.django_db(databases=['default', settings.LEADGEN_DB])
def test_some_case():
...
Package versions:
pytest-django==4.3.0
Django==3.2.3
Metadata
Metadata
Assignees
Labels
No labels