diff options
| author | Marco Aurélio da Rosa Haubrich <marhaubrich@ucs.br> | 2026-02-18 17:11:14 -0300 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-02-21 09:37:46 -0500 |
| commit | f45bfa5e2801545c1c8787f59bee3867c9928871 (patch) | |
| tree | 1f162441d62d79017789270c2a63ccbe775c9fc2 /tests/contenttypes_tests | |
| parent | 04613791af21a124299e0883bcbd6bd3fa0ab51f (diff) | |
Fixed #36935 -- Added fallback in ContentType.app_labeled_name when model_class() is None.
Updated ContentType.app_labeled_name to include the app_label in its string representation.
This removed ambiguity for content types whose models were not present in the current codebase
(for example, when multiple applications share the same database).
Adjusted related tests to reflect the new representation.
Diffstat (limited to 'tests/contenttypes_tests')
| -rw-r--r-- | tests/contenttypes_tests/test_models.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/contenttypes_tests/test_models.py b/tests/contenttypes_tests/test_models.py index b63c57ef09..542f0c8fd8 100644 --- a/tests/contenttypes_tests/test_models.py +++ b/tests/contenttypes_tests/test_models.py @@ -145,7 +145,7 @@ class ContentTypesTests(TestCase): ct = ContentType.objects.get_for_model(ModelCreatedOnTheFly) self.assertEqual(ct.app_label, "contenttypes_tests") self.assertEqual(ct.model, "modelcreatedonthefly") - self.assertEqual(str(ct), "modelcreatedonthefly") + self.assertEqual(str(ct), "contenttypes_tests | modelcreatedonthefly") def test_get_for_concrete_model(self): """ @@ -269,7 +269,7 @@ class ContentTypesTests(TestCase): app_label="contenttypes", model="OldModel", ) - self.assertEqual(str(ct), "OldModel") + self.assertEqual(str(ct), "contenttypes | OldModel") self.assertIsNone(ct.model_class()) # Stale ContentTypes can be fetched like any other object. @@ -318,7 +318,7 @@ class ContentTypesTests(TestCase): def test_app_labeled_name_unknown_model(self): ct = ContentType(app_label="contenttypes_tests", model="unknown") - self.assertEqual(ct.app_labeled_name, "unknown") + self.assertEqual(ct.app_labeled_name, "contenttypes_tests | unknown") class TestRouter: |
