summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_discovery_sample3/tests_transaction_test_case_mixed.py15
-rw-r--r--tests/test_runner/test_discover_runner.py17
2 files changed, 23 insertions, 9 deletions
diff --git a/tests/test_discovery_sample3/tests_transaction_test_case_mixed.py b/tests/test_discovery_sample3/tests_transaction_test_case_mixed.py
index ac72238e11..13059bbb87 100644
--- a/tests/test_discovery_sample3/tests_transaction_test_case_mixed.py
+++ b/tests/test_discovery_sample3/tests_transaction_test_case_mixed.py
@@ -1,6 +1,8 @@
from unittest import TestCase
-from django.test import TestCase as DjangoTestCase, TransactionTestCase
+from django.test import (
+ TestCase as DjangoTestCase, TransactionTestCase, skipUnlessDBFeature,
+)
class TestVanillaUnittest(TestCase):
@@ -29,8 +31,19 @@ class TestTransactionTestCase2(TransactionTestCase):
self.assertEqual(1, 1)
+# django.test.runner.reorder_postprocess() ignores this skipped test when
+# assigning _next_serialized_rollback.
+@skipUnlessDBFeature('nonexistent')
class TestTransactionTestCase3(TransactionTestCase):
available_apps = ['test_discovery_sample3']
+ serialized_rollback = True
+
+ def test_sample(self):
+ self.assertEqual(1, 1)
+
+
+class TestTransactionTestCase4(TransactionTestCase):
+ available_apps = ['test_discovery_sample3']
serialized_rollback = False
def test_sample(self):
diff --git a/tests/test_runner/test_discover_runner.py b/tests/test_runner/test_discover_runner.py
index 8887f2d22d..efc055978d 100644
--- a/tests/test_runner/test_discover_runner.py
+++ b/tests/test_runner/test_discover_runner.py
@@ -234,20 +234,21 @@ class DiscoverRunnerTests(SimpleTestCase):
def test_transaction_test_case_next_serialized_rollback_option(self):
runner = DiscoverRunner()
suite = runner.build_suite(['test_discovery_sample3.tests_transaction_test_case_mixed'])
- django_test_case, first_transaction_test_case, middle_transaction_test_case, \
- last_transaction_test_case, vanilla_test_case = suite
+ django_test_case, first_transaction_test_case, second_transaction_test_case, \
+ third_transaction_test_case, fourth_transaction_test_case, vanilla_test_case = suite
# TransactionTestCase1._next_serialized_rollback is
# TransactionTestCase2.serialize_rollback.
self.assertEqual(
first_transaction_test_case._next_serialized_rollback,
- middle_transaction_test_case.serialized_rollback
+ second_transaction_test_case.serialized_rollback
)
# TransactionTestCase2._next_serialized_rollback is
- # TransactionTestCase3.serialize_rollback.
+ # TransactionTestCase4.serialize_rollback because TransactionTestCase3
+ # is skipped.
self.assertEqual(
- middle_transaction_test_case._next_serialized_rollback,
- last_transaction_test_case.serialized_rollback
+ second_transaction_test_case._next_serialized_rollback,
+ fourth_transaction_test_case.serialized_rollback
)
# The last TransactionTestCase of the suite has
- # _next_serialized_rollback to = True.
- self.assertIs(last_transaction_test_case._next_serialized_rollback, True)
+ # _next_serialized_rollback = True.
+ self.assertIs(fourth_transaction_test_case._next_serialized_rollback, True)