Fixed #33014 -- Made ProjectState raise exception when real_apps argument is not a set.
This commit is contained in:
parent
4e8121e8e4
commit
7800596924
|
@ -91,10 +91,11 @@ class ProjectState:
|
|||
def __init__(self, models=None, real_apps=None):
|
||||
self.models = models or {}
|
||||
# Apps to include from main registry, usually unmigrated ones
|
||||
if real_apps:
|
||||
self.real_apps = real_apps if isinstance(real_apps, set) else set(real_apps)
|
||||
if real_apps is None:
|
||||
real_apps = set()
|
||||
else:
|
||||
self.real_apps = set()
|
||||
assert isinstance(real_apps, set)
|
||||
self.real_apps = real_apps
|
||||
self.is_delayed = False
|
||||
# {remote_model_key: {model_key: [(field_name, field)]}}
|
||||
self.relations = None
|
||||
|
|
|
@ -544,6 +544,10 @@ Miscellaneous
|
|||
* The undocumented ``TRANSLATOR_COMMENT_MARK`` constant is moved from
|
||||
``django.template.base`` to ``django.utils.translation.template``.
|
||||
|
||||
* The ``real_apps`` argument of the undocumented
|
||||
``django.db.migrations.state.ProjectState.__init__()`` method must now be a
|
||||
set if provided.
|
||||
|
||||
.. _deprecated-features-4.0:
|
||||
|
||||
Features deprecated in 4.0
|
||||
|
|
|
@ -924,6 +924,10 @@ class StateTests(SimpleTestCase):
|
|||
1,
|
||||
)
|
||||
|
||||
def test_real_apps_non_set(self):
|
||||
with self.assertRaises(AssertionError):
|
||||
ProjectState(real_apps=['contenttypes'])
|
||||
|
||||
def test_ignore_order_wrt(self):
|
||||
"""
|
||||
Makes sure ProjectState doesn't include OrderWrt fields when
|
||||
|
|
Loading…
Reference in New Issue