test_transactiontestcase.py 968 B

12345678910111213141516171819202122232425262728
  1. from django.test import TransactionTestCase, mock
  2. class TestSerializedRollbackInhibitsPostMigrate(TransactionTestCase):
  3. """
  4. TransactionTestCase._fixture_teardown() inhibits the post_migrate signal
  5. for test classes with serialized_rollback=True.
  6. """
  7. available_apps = ['test_utils']
  8. serialized_rollback = True
  9. def setUp(self):
  10. # self.available_apps must be None to test the serialized_rollback
  11. # condition.
  12. self.available_apps = None
  13. def tearDown(self):
  14. self.available_apps = ['test_utils']
  15. @mock.patch('django.test.testcases.call_command')
  16. def test(self, call_command):
  17. # with a mocked call_command(), this doesn't have any effect.
  18. self._fixture_teardown()
  19. call_command.assert_called_with(
  20. 'flush', interactive=False, allow_cascade=False,
  21. reset_sequences=False, inhibit_post_migrate=True,
  22. database='default', verbosity=0,
  23. )