mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #24397 -- Sped up model reloading in ProjectState.
Created bulk_update() context manager on StateApps. Sped up unregistering models in reload_models() by using this context mananger.
This commit is contained in:
committed by
Tim Graham
parent
6387d9d41f
commit
039d7881b4
@@ -160,6 +160,22 @@ class StateTests(TestCase):
|
||||
self.assertEqual([mgr.args for name, mgr in food_order_manager_state.managers],
|
||||
[('a', 'b', 1, 2), ('x', 'y', 3, 4)])
|
||||
|
||||
def test_apps_bulk_update(self):
|
||||
"""
|
||||
StateApps.bulk_update() should update apps.ready to False and reset
|
||||
the value afterwards.
|
||||
"""
|
||||
project_state = ProjectState()
|
||||
apps = project_state.apps
|
||||
with apps.bulk_update():
|
||||
self.assertFalse(apps.ready)
|
||||
self.assertTrue(apps.ready)
|
||||
with self.assertRaises(ValueError):
|
||||
with apps.bulk_update():
|
||||
self.assertFalse(apps.ready)
|
||||
raise ValueError()
|
||||
self.assertTrue(apps.ready)
|
||||
|
||||
def test_render(self):
|
||||
"""
|
||||
Tests rendering a ProjectState into an Apps.
|
||||
|
||||
Reference in New Issue
Block a user