Skip to content

With both db and transactional_db, database access might be denied for db #126

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

Closed
blueyed opened this issue Jul 8, 2014 · 2 comments
Closed

Comments

@blueyed
Copy link
Contributor

blueyed commented Jul 8, 2014

If you have fixtures that use db and transactional_db, you might get a Database access not allowed, use the "django_db" mark to enable error, if you use the fixture using db before the one using transactional_db.

The reason is that db skips enabling the database, if it finds transactional_db in the fixturenames.

I will provide a failing test, but am not sure about how this should get fixed.
Maybe the transactional db setup should get triggered / called from the db fixture in this case?

blueyed added a commit to blueyed/pytest-django that referenced this issue Jul 8, 2014
@flub
Copy link
Member

flub commented Jul 9, 2014

Interesting edge case. Your suggestion is probably the best course, instead of not doing anything call the transactional setup if transactional is detected.

blueyed added a commit to blueyed/pytest-django that referenced this issue Jul 9, 2014
This adds a new helper method (`_django_db_fixture_helper`), which is
being called from `db` and `transaction_db`.

The intermediate helper function (in contrast to using an internal fixture)
is necessary for setting up the `django_db` mark.

Fixes pytest-dev#126
@blueyed
Copy link
Contributor Author

blueyed commented Jul 9, 2014

Thanks for your feedback.

I have been affected by this before already probably, but only got confused back then.

It turned out to be a bit more involving than I've expected, but there is a PR now to fix it.

beyondgeeks pushed a commit to beyondgeeks/django-pytest that referenced this issue Sep 6, 2022
This adds a new helper method (`_django_db_fixture_helper`), which is
being called from `db` and `transaction_db`.

The intermediate helper function (in contrast to using an internal fixture)
is necessary for setting up the `django_db` mark.

Fixes pytest-dev/pytest-django#126
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

Successfully merging a pull request may close this issue.

2 participants