瀏覽代碼

Added file forgotten in previous commit, plus one more test.

Aymeric Augustin 11 年之前
父節點
當前提交
cfbdd587f6
共有 2 個文件被更改,包括 32 次插入1 次删除
  1. 27 0
      tests/apps/apps.py
  2. 5 1
      tests/apps/tests.py

+ 27 - 0
tests/apps/apps.py

@@ -0,0 +1,27 @@
+from __future__ import unicode_literals
+
+from django.apps import AppConfig
+
+
+class MyAdmin(AppConfig):
+    name = 'django.contrib.admin'
+    verbose_name = "Admin sweet admin."
+
+
+class MyAuth(AppConfig):
+    name = 'django.contrib.auth'
+    verbose_name = "All your password are belong to us."
+
+
+class BadConfig(AppConfig):
+    """This class doesn't supply the mandatory 'name' attribute."""
+
+
+class NotAConfig(object):
+    name = 'apps'
+
+
+class NoSuchApp(AppConfig):
+    name = 'there is no such app'
+
+

+ 5 - 1
tests/apps/tests.py

@@ -73,8 +73,12 @@ class AppsTests(TestCase):
 
     def test_no_such_app(self):
         """
-        Tests when INSTALLED_APPS contains an app config for an app that doesn't exist.
+        Tests when INSTALLED_APPS contains an app that doesn't exist, either
+        directly or via an app config.
         """
+        with self.assertRaises(ImportError):
+            with self.settings(INSTALLED_APPS=['there is no such app']):
+                pass
         with self.assertRaises(ImportError):
             with self.settings(INSTALLED_APPS=['apps.apps.NoSuchApp']):
                 pass