Loading django/apps/registry.py +6 −1 Original line number Diff line number Diff line Loading @@ -147,7 +147,12 @@ class Apps(object): try: return self.app_configs[app_label] except KeyError: raise LookupError("No installed app with label '%s'." % app_label) message = "No installed app with label '%s'." % app_label for app_config in self.get_app_configs(): if app_config.name == app_label: message += " Did you mean '%s'?" % app_config.label break raise LookupError(message) # This method is performance-critical at least for Django's test suite. @lru_cache.lru_cache(maxsize=None) Loading django/core/management/commands/dumpdata.py +6 −6 Original line number Diff line number Diff line Loading @@ -68,8 +68,8 @@ class Command(BaseCommand): else: try: app_config = apps.get_app_config(exclude) except LookupError: raise CommandError('Unknown app in excludes: %s' % exclude) except LookupError as e: raise CommandError(str(e)) excluded_apps.add(app_config) if len(app_labels) == 0: Loading @@ -87,8 +87,8 @@ class Command(BaseCommand): app_label, model_label = label.split('.') try: app_config = apps.get_app_config(app_label) except LookupError: raise CommandError("Unknown application: %s" % app_label) except LookupError as e: raise CommandError(str(e)) if app_config.models_module is None or app_config in excluded_apps: continue try: Loading @@ -111,8 +111,8 @@ class Command(BaseCommand): app_label = label try: app_config = apps.get_app_config(app_label) except LookupError: raise CommandError("Unknown application: %s" % app_label) except LookupError as e: raise CommandError(str(e)) if app_config.models_module is None or app_config in excluded_apps: continue app_list[app_config] = None Loading tests/apps/tests.py +4 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,10 @@ class AppsTests(SimpleTestCase): with self.assertRaises(LookupError): apps.get_app_config('webdesign') msg = "No installed app with label 'django.contrib.auth'. Did you mean 'myauth'" with self.assertRaisesMessage(LookupError, msg): apps.get_app_config('django.contrib.auth') @override_settings(INSTALLED_APPS=SOME_INSTALLED_APPS) def test_is_installed(self): """ Loading tests/fixtures/tests.py +1 −1 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase): # Excluding a bogus app should throw an error with six.assertRaisesRegex(self, management.CommandError, "Unknown app in excludes: foo_app"): "No installed app with label 'foo_app'."): self._dumpdata_assert(['fixtures', 'sites'], '', exclude_list=['foo_app']) # Excluding a bogus model should throw an error Loading Loading
django/apps/registry.py +6 −1 Original line number Diff line number Diff line Loading @@ -147,7 +147,12 @@ class Apps(object): try: return self.app_configs[app_label] except KeyError: raise LookupError("No installed app with label '%s'." % app_label) message = "No installed app with label '%s'." % app_label for app_config in self.get_app_configs(): if app_config.name == app_label: message += " Did you mean '%s'?" % app_config.label break raise LookupError(message) # This method is performance-critical at least for Django's test suite. @lru_cache.lru_cache(maxsize=None) Loading
django/core/management/commands/dumpdata.py +6 −6 Original line number Diff line number Diff line Loading @@ -68,8 +68,8 @@ class Command(BaseCommand): else: try: app_config = apps.get_app_config(exclude) except LookupError: raise CommandError('Unknown app in excludes: %s' % exclude) except LookupError as e: raise CommandError(str(e)) excluded_apps.add(app_config) if len(app_labels) == 0: Loading @@ -87,8 +87,8 @@ class Command(BaseCommand): app_label, model_label = label.split('.') try: app_config = apps.get_app_config(app_label) except LookupError: raise CommandError("Unknown application: %s" % app_label) except LookupError as e: raise CommandError(str(e)) if app_config.models_module is None or app_config in excluded_apps: continue try: Loading @@ -111,8 +111,8 @@ class Command(BaseCommand): app_label = label try: app_config = apps.get_app_config(app_label) except LookupError: raise CommandError("Unknown application: %s" % app_label) except LookupError as e: raise CommandError(str(e)) if app_config.models_module is None or app_config in excluded_apps: continue app_list[app_config] = None Loading
tests/apps/tests.py +4 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,10 @@ class AppsTests(SimpleTestCase): with self.assertRaises(LookupError): apps.get_app_config('webdesign') msg = "No installed app with label 'django.contrib.auth'. Did you mean 'myauth'" with self.assertRaisesMessage(LookupError, msg): apps.get_app_config('django.contrib.auth') @override_settings(INSTALLED_APPS=SOME_INSTALLED_APPS) def test_is_installed(self): """ Loading
tests/fixtures/tests.py +1 −1 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase): # Excluding a bogus app should throw an error with six.assertRaisesRegex(self, management.CommandError, "Unknown app in excludes: foo_app"): "No installed app with label 'foo_app'."): self._dumpdata_assert(['fixtures', 'sites'], '', exclude_list=['foo_app']) # Excluding a bogus model should throw an error Loading