Commit 39bbd165 authored by Gabriel Hurley's avatar Gabriel Hurley
Browse files

Fixed #7198 (again) -- Corrects a problem with string interpolation from...

Fixed #7198 (again) -- Corrects a problem with string interpolation from r16876 and adds tests for the new error message.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@16888 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent bb641631
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ class AppCache(object):
                    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)
+0 −0

Empty file added.

+5 −0
Original line number Diff line number Diff line
from django.test import TestCase

class NoModelTests(TestCase):
    """ A placeholder test case. See modeltests.empty.tests for more info. """
    pass
+22 −0
Original line number Diff line number Diff line
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 @@ class EmptyModelTests(TestCase):
        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')