diff options
| author | romgar <romain.garrigues.cs@gmail.com> | 2016-11-07 22:08:40 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-11-06 16:57:50 -0500 |
| commit | b3b1d3d45fc066367f4fcacf0b06f72fcd00a9c6 (patch) | |
| tree | d6e9a8846da45a0afe642a2957f2ed7dbf286336 /tests/test_runner | |
| parent | ecac6d7a2a510cb0a5d772deeca633c99c9687e5 (diff) | |
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.
Diffstat (limited to 'tests/test_runner')
| -rw-r--r-- | tests/test_runner/test_discover_runner.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_runner/test_discover_runner.py b/tests/test_runner/test_discover_runner.py index e7c7e4dad1..d16757637e 100644 --- a/tests/test_runner/test_discover_runner.py +++ b/tests/test_runner/test_discover_runner.py @@ -223,3 +223,31 @@ class DiscoverRunnerTest(TestCase): with captured_stdout() as stdout: runner.build_suite(['test_runner_apps.tagged.tests']) self.assertIn('Excluding test tag(s): bar, foo.\n', stdout.getvalue()) + + def test_transaction_test_case_before_simple_test_case(self): + runner = DiscoverRunner() + suite = runner.build_suite(['test_discovery_sample3.tests_transaction_test_case_ordering']) + suite = tuple(suite) + # TransactionTestCase is second after TestCase. + self.assertIn('TestTransactionTestCase', suite[1].id()) + + 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 + # TransactionTestCase1._next_serialized_rollback is + # TransactionTestCase2.serialize_rollback. + self.assertEqual( + first_transaction_test_case._next_serialized_rollback, + middle_transaction_test_case.serialized_rollback + ) + # TransactionTestCase2._next_serialized_rollback is + # TransactionTestCase3.serialize_rollback. + self.assertEqual( + middle_transaction_test_case._next_serialized_rollback, + last_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) |
