mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +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:
parent
54790e669d
commit
ba7206cd81
20 changed files with 80 additions and 53 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue