mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Changed get_model to raise an exception on errors.
Returning None on errors required unpythonic error checking and was inconsistent with get_app_config. get_model was a private API until the previous commit, but given that it was certainly used in third party software, the change is explained in the release notes. Applied the same change to get_registered_model, which is a new private API introduced during the recent refactoring.
This commit is contained in:
@@ -72,8 +72,8 @@ class GetModelsTest(TestCase):
|
||||
self.not_installed_module = models
|
||||
|
||||
def test_get_model_only_returns_installed_models(self):
|
||||
self.assertEqual(
|
||||
apps.get_model("not_installed", "NotInstalledModel"), None)
|
||||
with self.assertRaises(LookupError):
|
||||
apps.get_model("not_installed", "NotInstalledModel")
|
||||
|
||||
def test_get_models_only_returns_installed_models(self):
|
||||
self.assertNotIn(
|
||||
|
||||
Reference in New Issue
Block a user