-
Notifications
You must be signed in to change notification settings - Fork 352
Closed
Labels
Description
Hi, is this note still true?
pytest-django/docs/helpers.rst
Lines 43 to 48 in 4145f73
| If you want access to the Django database *inside a fixture* | |
| this marker will not help even if the function requesting your | |
| fixture has this marker applied. To access the database in a | |
| fixture, the fixture itself will have to request the ``db`` or | |
| ``transactional_db`` fixture. See below for a description of | |
| them. |
This works for me:
import pytest
from django.contrib.auth.models import User
@pytest.fixture
def dbusers():
return User.objects.count()
@pytest.mark.django_db
def test_usercount(dbusers):
assert dbusers == 0Thanks for your work on pytest-django!