﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16885	django.test.testcases.connections_support_transactions always returns False if TEST_MIRROR is used	grimfandjango	nobody	"If a project is set up with multiple databases, and at least one of the databases uses the TEST_MIRROR option, django.test.testcases.connections_support_transactions will always return False, forcing any tests inheriting from TestCase into the (substantially slower) TransactionTestCase mode.

Example: take the test case:


{{{
    class TestTest(TestCase):
        def test_connections_support_transactions(self):
            import django.test.testcases
            self.assertTrue(django.test.testcases.connections_support_transactions())
}}}


and the database setup:


{{{
    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', 
        'NAME': '/tmp/foo.db',                      # Or path to database file if using sqlite3.
    }
    }
}}}

    
Test output:


{{{
    Creating test database for alias 'default'...
    .
    ----------------------------------------------------------------------
    Ran 1 test in 0.000s

    OK
}}}


Switch to:


{{{
    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', 
        'NAME': '/tmp/foo.db',                      # Or path to database file if using sqlite3.
    },    
    'reporting': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': '/tmp/foo2.db',   
            'TEST_MIRROR': 'default',                 
    }
    }
}}}


Test output:


{{{
    FAIL: test_connections_support_transactions (foo.testit.tests.TestTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File ""/../venvs/django_svn/foo/../foo/testit/tests.py"", line 15, in test_connections_support_transactions
        self.assertTrue(django.test.testcases.connections_support_transactions())
    AssertionError: False is not True

}}}

The same problem occurs with the MySQL backend if configured analogously.

The underlying issue is that in ''conn.features.supports_transactions for conn in connections.all()'' in connections_support_transactions, ''conn.features.supports_transactions'' is ''None'' for the alias."	Bug	closed	Testing framework	dev	Normal	fixed		m.vantellingen@…	Accepted	1	0	0	0	0	0
