summaryrefslogtreecommitdiff
path: root/tests/model_inheritance
diff options
context:
space:
mode:
authorThomas Chaumeny <t.chaumeny@gmail.com>2014-10-18 23:01:13 +0200
committerTim Graham <timograham@gmail.com>2014-12-03 10:37:04 -0500
commitda9fe5c717c179a9e881a40efd3bfe36a21bf4a6 (patch)
treebdf38ea36841d93fa9260daf5b8d705b377dbd40 /tests/model_inheritance
parentdee4d23f7e703aec2d1244e4facbf7f4c88deed5 (diff)
downloaddjango-da9fe5c717c179a9e881a40efd3bfe36a21bf4a6.tar.gz
Fixed #20392 -- Added TestCase.setUpTestData()
Each TestCase is also now wrapped in a class-wide transaction.
Diffstat (limited to 'tests/model_inheritance')
-rw-r--r--tests/model_inheritance/tests.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py
index 19d7b5650f..bf76286391 100644
--- a/tests/model_inheritance/tests.py
+++ b/tests/model_inheritance/tests.py
@@ -5,7 +5,7 @@ from operator import attrgetter
from django.core.exceptions import FieldError
from django.core.management import call_command
from django.db import connection
-from django.test import TestCase
+from django.test import TestCase, TransactionTestCase
from django.test.utils import CaptureQueriesContext
from django.utils import six
@@ -379,7 +379,9 @@ class ModelInheritanceTests(TestCase):
s.titles.all(), [])
-class InheritanceSameModelNameTests(TestCase):
+class InheritanceSameModelNameTests(TransactionTestCase):
+
+ available_apps = ['model_inheritance']
def setUp(self):
# The Title model has distinct accessors for both
@@ -402,14 +404,19 @@ class InheritanceSameModelNameTests(TestCase):
INSTALLED_APPS={'append': ['model_inheritance.same_model_name']}):
call_command('migrate', verbosity=0)
from .same_model_name.models import Copy
+ copy = self.title.attached_same_model_name_copy_set.create(
+ content='The Web framework for perfectionists with deadlines.',
+ url='http://www.djangoproject.com/',
+ title='Django Rocks'
+ )
self.assertEqual(
- self.title.attached_same_model_name_copy_set.create(
- content='The Web framework for perfectionists with deadlines.',
- url='http://www.djangoproject.com/',
- title='Django Rocks'
- ), Copy.objects.get(
+ copy,
+ Copy.objects.get(
content='The Web framework for perfectionists with deadlines.',
))
+ # We delete the copy manually so that it doesn't block the flush
+ # command under Oracle (which does not cascade deletions).
+ copy.delete()
def test_related_name_attribute_exists(self):
# The Post model doesn't have an attribute called 'attached_%(app_label)s_%(class)s_set'.