Fix regression: pull in all databases instead of default database#1193
Fix regression: pull in all databases instead of default database#1193xi wants to merge 1 commit intopytest-dev:mainfrom
Conversation
| @@ -147,9 +147,7 @@ def _get_databases_for_test(test: pytest.Item) -> tuple[Iterable[str], bool]: | |||
| databases = None | |||
| else: | |||
| return (), False | |||
There was a problem hiding this comment.
This code path is also problematic, and what I am running into since the test itself isn't decorated with anything so the fixtures list does not include any that are mentioned above.
| from django.test import TestCase | ||
| from .app.models import Item, SecondItem | ||
|
|
||
| TestCase.databases = ["default", "second"] |
There was a problem hiding this comment.
@bluetech is this something we want to support?
I thought the pytest_django-way was to use @pytest.mark.django_db(databases={"default", "second"})
|
I don't think we should make this change as it deviates from Django's behavior -- the default is to only request the default database as described here: https://docs.djangoproject.com/en/6.0/topics/testing/tools/#multi-database-support The actual problem is the extra dynamism that pytest enables and you are taking advantage of (using fixtures instead of statically declaring the databases). I will discuss this more in the issue. |
fixes #1192