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

Cannot access db in fixtures at 'session' level. #388

Closed
ludbek opened this issue Sep 5, 2016 · 3 comments
Closed

Cannot access db in fixtures at 'session' level. #388

ludbek opened this issue Sep 5, 2016 · 3 comments

Comments

@ludbek
Copy link

ludbek commented Sep 5, 2016

I am trying to auto use a fixture at session level. So I kept the fixture at conftest.py. The code is as follows.

import pytest

pytestmark = [
    pytest.mark.django_db(transaction = True),]

@pytest.fixture(scope="session", autouse = True)
def afixture():
    a_func_which_talks_to_db()

Running test throws following error.
Failed: Database access not allowed, use the "django_db" mark to enable it.

@ludbek
Copy link
Author

ludbek commented Feb 27, 2017

ping

@goetzk
Copy link

goetzk commented Mar 9, 2018

I have no help to offer particularly, other than to note while researching a different problem I've seen issues (like #33) which mention the scope must be function. I'm not sure if that is still the case but YVMV.

@blueyed
Copy link
Contributor

blueyed commented Apr 11, 2019

Closing as duplicate of #514.

@blueyed blueyed closed this as completed Apr 11, 2019
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

3 participants