From b3b1d3d45fc066367f4fcacf0b06f72fcd00a9c6 Mon Sep 17 00:00:00 2001 From: romgar Date: Mon, 7 Nov 2016 22:08:40 +0000 Subject: Fixed #25251 -- Made data migrations available in TransactionTestCase when using --keepdb. Data loaded in migrations were restored at the beginning of each TransactionTestCase and all the tables are truncated at the end of these test cases. If there was a TransactionTestCase at the end of the test suite, the migrated data weren't restored in the database (especially unexpected when using --keepdb). Now data is restored at the end of each TransactionTestCase. --- tests/test_discovery_sample3/__init__.py | 0 .../tests_transaction_test_case_mixed.py | 37 ++++++++++++++++++++++ .../tests_transaction_test_case_ordering.py | 28 ++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 tests/test_discovery_sample3/__init__.py create mode 100644 tests/test_discovery_sample3/tests_transaction_test_case_mixed.py create mode 100644 tests/test_discovery_sample3/tests_transaction_test_case_ordering.py (limited to 'tests/test_discovery_sample3') diff --git a/tests/test_discovery_sample3/__init__.py b/tests/test_discovery_sample3/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_discovery_sample3/tests_transaction_test_case_mixed.py b/tests/test_discovery_sample3/tests_transaction_test_case_mixed.py new file mode 100644 index 0000000000..ac72238e11 --- /dev/null +++ b/tests/test_discovery_sample3/tests_transaction_test_case_mixed.py @@ -0,0 +1,37 @@ +from unittest import TestCase + +from django.test import TestCase as DjangoTestCase, TransactionTestCase + + +class TestVanillaUnittest(TestCase): + def test_sample(self): + self.assertEqual(1, 1) + + +class TestDjangoTestCase(DjangoTestCase): + def test_sample(self): + self.assertEqual(1, 1) + + +class TestTransactionTestCase1(TransactionTestCase): + available_apps = ['test_discovery_sample3'] + serialized_rollback = False + + def test_sample(self): + self.assertEqual(1, 1) + + +class TestTransactionTestCase2(TransactionTestCase): + available_apps = ['test_discovery_sample3'] + serialized_rollback = True + + def test_sample(self): + self.assertEqual(1, 1) + + +class TestTransactionTestCase3(TransactionTestCase): + available_apps = ['test_discovery_sample3'] + serialized_rollback = False + + def test_sample(self): + self.assertEqual(1, 1) diff --git a/tests/test_discovery_sample3/tests_transaction_test_case_ordering.py b/tests/test_discovery_sample3/tests_transaction_test_case_ordering.py new file mode 100644 index 0000000000..8d79bc08a6 --- /dev/null +++ b/tests/test_discovery_sample3/tests_transaction_test_case_ordering.py @@ -0,0 +1,28 @@ +from unittest import TestCase + +from django.test import ( + SimpleTestCase, TestCase as DjangoTestCase, TransactionTestCase, +) + + +class TestDjangoTestCase(DjangoTestCase): + def test_sample(self): + self.assertEqual(1, 1) + + +class TestVanillaUnittest(TestCase): + def test_sample(self): + self.assertEqual(1, 1) + + +class TestZimpleTestCase(SimpleTestCase): + # Z gets this test to appear after Vanilla in the default suite. + def test_sample(self): + self.assertEqual(1, 1) + + +class TestTransactionTestCase(TransactionTestCase): + available_apps = ['test_discovery_sample3'] + + def test_sample(self): + self.assertEqual(1, 1) -- cgit v1.3