-
Notifications
You must be signed in to change notification settings - Fork 349
Description
Since #1186 (release 4.11.1 I think) during test runs when selecting only one test case it fails with postgresql error database X does not exist as it tries to access the normal X database name instead of the test_X which should have been initialized. My tests look like this:
# conftest.py
@pytest.fixture
def app(db):
.....
# tests/test_something.py
class TestClass:
@pytest.fixture
def app(self, app): # LINE XXX
.....
def test_something(self, app):
......
If i run pytest with -k test_something pytest-django insists on accessing the database myapp instead of test_myapp which has been initialized. Neithe have been initialized anyway. I traced the problem in _get_databases_for_test() on these lines:
fixtures = getattr(test, "fixturenames", ())
....
elif "db" in fixtures or "transactional_db" in fixtures or "live_server" in fixtures:
db is never found in fixtures, but if I add 'db' to the fixture signature on LINE XXX in test_something.py, then it works. It seems pytest is not correctly reporting the fixtures from overridden fixtures, don't know it it's a bug in pytest or a misuse of pytest API by pytest-django.