Ticket #18984: 18984-fix-without-multi-db.diff

File 18984-fix-without-multi-db.diff, 834 bytes (added by Aymeric Augustin, 7 years ago)
  • django/test/testcases.py

    diff --git a/django/test/testcases.py b/django/test/testcases.py
    index 96178b4..0f76e11 100644
    a b class TransactionTestCase(SimpleTestCase): 
    505505        # If the test case has a multi_db=True flag, flush all databases.
    506506        # Otherwise, just flush default.
    507507        databases = connections if getattr(self, 'multi_db', False) else [DEFAULT_DB_ALIAS]
     508
     509        # Roll back any pending transactions in order to avoid a deadlock
     510        # during flush when TEST_MIRROR is used (#18984).
     511        for conn in connections.all():
     512            conn.rollback_unless_managed()
     513
    508514        for db in databases:
    509515            call_command('flush', verbosity=0, interactive=False, database=db,
    510516                         skip_validation=True, reset_sequences=False)
Back to Top