Ticket #7198: 7198_fix_with_tests.diff
File 7198_fix_with_tests.diff, 2.5 KB (added by , 13 years ago) |
---|
-
tests/modeltests/empty/no_models/tests.py
1 from django.test import TestCase 2 3 class NoModelTests(TestCase): 4 """ A placeholder test case. See modeltests.empty.tests for more info. """ 5 pass -
tests/modeltests/empty/tests.py
1 from __future__ import with_statement 2 3 from django.conf import settings 4 from django.core.exceptions import ImproperlyConfigured 5 from django.db.models.loading import get_app 1 6 from django.test import TestCase 7 from django.test.utils import override_settings 2 8 3 9 from models import Empty 4 10 … … 13 19 self.assertTrue(m.id is not None) 14 20 existing = Empty(m.id) 15 21 existing.save() 22 23 class NoModelTests(TestCase): 24 """ 25 Test for #7198 to ensure that the proper error message is raised 26 when attempting to load an app with no models.py file. 27 28 Becuase the test runner won't currently load a test module with no 29 models.py file, this TestCase instead lives in this module. 30 31 It seemed like an appropriate home for it. 32 """ 33 @override_settings(INSTALLED_APPS=("modeltests.empty.no_models",)) 34 def test_no_models(self): 35 with self.assertRaisesRegexp(ImproperlyConfigured, 36 'App with label no_models is missing a models.py module.'): 37 get_app('no_models') -
django/db/models/loading.py
146 146 if mod is None: 147 147 if emptyOK: 148 148 return None 149 raise ImproperlyConfigured("App with label %s is missing a models.py module." )149 raise ImproperlyConfigured("App with label %s is missing a models.py module." % app_label) 150 150 else: 151 151 return mod 152 152 raise ImproperlyConfigured("App with label %s could not be found" % app_label)