diff options
author | Florian Apolloner <florian@apolloner.eu> | 2013-02-26 09:53:47 +0100 |
---|---|---|
committer | Florian Apolloner <florian@apolloner.eu> | 2013-02-26 14:36:57 +0100 |
commit | 89f40e36246100df6a11316c31a76712ebc6c501 (patch) | |
tree | 6e65639683ddaf2027908d1ecb1739e0e2ff853b /tests/empty | |
parent | b3d2ccb5bfbaf6e7fe1f98843baaa48c35a70950 (diff) | |
download | django-89f40e36246100df6a11316c31a76712ebc6c501.tar.gz |
Merged regressiontests and modeltests into the test root.
Diffstat (limited to 'tests/empty')
-rw-r--r-- | tests/empty/__init__.py | 0 | ||||
-rw-r--r-- | tests/empty/models.py | 12 | ||||
-rw-r--r-- | tests/empty/no_models/__init__.py | 0 | ||||
-rw-r--r-- | tests/empty/no_models/tests.py | 6 | ||||
-rw-r--r-- | tests/empty/tests.py | 38 |
5 files changed, 56 insertions, 0 deletions
diff --git a/tests/empty/__init__.py b/tests/empty/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/empty/__init__.py diff --git a/tests/empty/models.py b/tests/empty/models.py new file mode 100644 index 0000000000..a6cdb0aa22 --- /dev/null +++ b/tests/empty/models.py @@ -0,0 +1,12 @@ +""" +40. Empty model tests + +These test that things behave sensibly for the rare corner-case of a model with +no fields. +""" + +from django.db import models + + +class Empty(models.Model): + pass diff --git a/tests/empty/no_models/__init__.py b/tests/empty/no_models/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/empty/no_models/__init__.py diff --git a/tests/empty/no_models/tests.py b/tests/empty/no_models/tests.py new file mode 100644 index 0000000000..6292ca9f74 --- /dev/null +++ b/tests/empty/no_models/tests.py @@ -0,0 +1,6 @@ +from django.test import TestCase + + +class NoModelTests(TestCase): + """ A placeholder test case. See modeltests.empty.tests for more info. """ + pass diff --git a/tests/empty/tests.py b/tests/empty/tests.py new file mode 100644 index 0000000000..4c0c4409d8 --- /dev/null +++ b/tests/empty/tests.py @@ -0,0 +1,38 @@ +from __future__ import absolute_import + +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 django.utils import six + +from .models import Empty + + +class EmptyModelTests(TestCase): + def test_empty(self): + m = Empty() + self.assertEqual(m.id, None) + m.save() + Empty.objects.create() + self.assertEqual(len(Empty.objects.all()), 2) + 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. + + Because 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 six.assertRaisesRegex(self, ImproperlyConfigured, + 'App with label no_models is missing a models.py module.'): + get_app('no_models') |