1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #34849 -- Avoided raising RuntimeWarning about import-time queries when apps are reinitialized with test tools.

Regression in fbd16438f4.
This commit is contained in:
David Sanders
2023-09-24 19:02:50 +10:00
committed by Mariusz Felisiak
parent 574ee4023e
commit 4f2ae0644d
3 changed files with 24 additions and 8 deletions

View File

@@ -607,10 +607,9 @@ class QueryPerformingAppTests(TransactionTestCase):
custom_settings = override_settings(
INSTALLED_APPS=[f"apps.query_performing_app.apps.{app_config_name}"]
)
# Ignore the RuntimeWarning, as override_settings.enable() calls
# AppConfig.ready() which will trigger the warning.
with self.assertWarnsMessage(RuntimeWarning, self.expected_msg):
custom_settings.enable()
custom_settings.enable()
old_stored_app_configs = apps.stored_app_configs
apps.stored_app_configs = []
try:
with patch.multiple(apps, ready=False, loading=False, app_configs={}):
with self.assertWarnsMessage(RuntimeWarning, self.expected_msg):
@@ -619,4 +618,5 @@ class QueryPerformingAppTests(TransactionTestCase):
app_config = apps.get_app_config("query_performing_app")
return app_config.query_results
finally:
setattr(apps, "stored_app_configs", old_stored_app_configs)
custom_settings.disable()