Author: gabrielhurley
Date: 2011-09-22 14:09:00 -0700 (Thu, 22 Sep 2011)
New Revision: 16888

Added:
   django/trunk/tests/modeltests/empty/no_models/
   django/trunk/tests/modeltests/empty/no_models/__init__.py
   django/trunk/tests/modeltests/empty/no_models/tests.py
Modified:
   django/trunk/django/db/models/loading.py
   django/trunk/tests/modeltests/empty/tests.py
Log:
Fixed #7198 (again) -- Corrects a problem with string interpolation from r16876 
and adds tests for the new error message.


Modified: django/trunk/django/db/models/loading.py
===================================================================
--- django/trunk/django/db/models/loading.py    2011-09-22 17:04:05 UTC (rev 
16887)
+++ django/trunk/django/db/models/loading.py    2011-09-22 21:09:00 UTC (rev 
16888)
@@ -146,7 +146,7 @@
                     if mod is None:
                         if emptyOK:
                             return None
-                        raise ImproperlyConfigured("App with label %s is 
missing a models.py module.")
+                        raise ImproperlyConfigured("App with label %s is 
missing a models.py module." % app_label)
                     else:
                         return mod
             raise ImproperlyConfigured("App with label %s could not be found" 
% app_label)

Added: django/trunk/tests/modeltests/empty/no_models/__init__.py
===================================================================
Added: django/trunk/tests/modeltests/empty/no_models/tests.py
===================================================================
--- django/trunk/tests/modeltests/empty/no_models/tests.py                      
        (rev 0)
+++ django/trunk/tests/modeltests/empty/no_models/tests.py      2011-09-22 
21:09:00 UTC (rev 16888)
@@ -0,0 +1,5 @@
+from django.test import TestCase
+
+class NoModelTests(TestCase):
+    """ A placeholder test case. See modeltests.empty.tests for more info. """
+    pass

Modified: django/trunk/tests/modeltests/empty/tests.py
===================================================================
--- django/trunk/tests/modeltests/empty/tests.py        2011-09-22 17:04:05 UTC 
(rev 16887)
+++ django/trunk/tests/modeltests/empty/tests.py        2011-09-22 21:09:00 UTC 
(rev 16888)
@@ -1,4 +1,10 @@
+from __future__ import with_statement
+
+from django.conf import settings
+from django.core.exceptions import ImproperlyConfigured
+from django.db.models.loading import get_app
 from django.test import TestCase
+from django.test.utils import override_settings
 
 from models import Empty
 
@@ -13,3 +19,19 @@
         self.assertTrue(m.id is not None)
         existing = Empty(m.id)
         existing.save()
+
+class NoModelTests(TestCase):
+    """
+    Test for #7198 to ensure that the proper error message is raised
+    when attempting to load an app with no models.py file.
+
+    Becuase the test runner won't currently load a test module with no
+    models.py file, this TestCase instead lives in this module.
+
+    It seemed like an appropriate home for it.
+    """
+    @override_settings(INSTALLED_APPS=("modeltests.empty.no_models",))
+    def test_no_models(self):
+        with self.assertRaisesRegexp(ImproperlyConfigured,
+                    'App with label no_models is missing a models.py module.'):
+            get_app('no_models')

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to