mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Merged regressiontests and modeltests into the test root.
This commit is contained in:
parent
b3d2ccb5bf
commit
89f40e3624
1050 changed files with 0 additions and 0 deletions
0
tests/empty/__init__.py
Normal file
0
tests/empty/__init__.py
Normal file
12
tests/empty/models.py
Normal file
12
tests/empty/models.py
Normal file
|
@ -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
|
0
tests/empty/no_models/__init__.py
Normal file
0
tests/empty/no_models/__init__.py
Normal file
6
tests/empty/no_models/tests.py
Normal file
6
tests/empty/no_models/tests.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.test import TestCase
|
||||
|
||||
|
||||
class NoModelTests(TestCase):
|
||||
""" A placeholder test case. See modeltests.empty.tests for more info. """
|
||||
pass
|
38
tests/empty/tests.py
Normal file
38
tests/empty/tests.py
Normal file
|
@ -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')
|
Loading…
Add table
Add a link
Reference in a new issue