1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Enforced unicity of app labels.

Fixed #21679.
This commit is contained in:
Aymeric Augustin
2013-12-31 17:25:57 +01:00
parent c40209dcc0
commit 63137a8304
4 changed files with 36 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ from django.apps.registry import Apps
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.test import TestCase, override_settings
from django.utils import six
from .models import TotallyNormal, SoAlternative, new_apps
@@ -115,6 +116,16 @@ class AppsTests(TestCase):
def test_relabeling(self):
self.assertEqual(apps.get_app_config('relabeled').name, 'apps')
def test_duplicate_labels(self):
with six.assertRaisesRegex(self, ImproperlyConfigured, "Application labels aren't unique"):
with self.settings(INSTALLED_APPS=['apps.apps.PlainAppsConfig', 'apps']):
pass
def test_duplicate_names(self):
with six.assertRaisesRegex(self, ImproperlyConfigured, "Application names aren't unique"):
with self.settings(INSTALLED_APPS=['apps.apps.RelabeledAppsConfig', 'apps']):
pass
def test_models_py(self):
"""
Tests that the models in the models.py file were loaded correctly.