Tweaked tests from r17702 to run only when using sqlite3 DB(s).

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17733 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Ramiro Morales 2012-03-14 10:58:23 +00:00
parent 9d1d1f06db
commit eb9eaa6d71
1 changed files with 8 additions and 12 deletions

View File

@ -9,6 +9,7 @@ import warnings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command from django.core.management import call_command
from django import db
from django.test import simple from django.test import simple
from django.test.simple import DjangoTestSuiteRunner, get_tests from django.test.simple import DjangoTestSuiteRunner, get_tests
from django.test.testcases import connections_support_transactions from django.test.testcases import connections_support_transactions
@ -218,7 +219,6 @@ class CustomTestRunnerOptionsTests(AdminScriptTestCase):
class Ticket16885RegressionTests(unittest.TestCase): class Ticket16885RegressionTests(unittest.TestCase):
def test_ticket_16885(self): def test_ticket_16885(self):
"""Features are also confirmed on mirrored databases.""" """Features are also confirmed on mirrored databases."""
from django import db
old_db_connections = db.connections old_db_connections = db.connections
try: try:
db.connections = db.ConnectionHandler({ db.connections = db.ConnectionHandler({
@ -266,9 +266,11 @@ class ModulesTestsPackages(unittest.TestCase):
class Sqlite3InMemoryTestDbs(unittest.TestCase): class Sqlite3InMemoryTestDbs(unittest.TestCase):
@unittest.skipUnless(all(db.connections[conn].vendor == 'sqlite' for conn in db.connections),
"This is a sqlite-specific issue")
def test_transaction_support(self): def test_transaction_support(self):
"""Ticket #16329: sqlite3 in-memory test databases""" """Ticket #16329: sqlite3 in-memory test databases"""
from django import db
old_db_connections = db.connections old_db_connections = db.connections
for option in ('NAME', 'TEST_NAME'): for option in ('NAME', 'TEST_NAME'):
try: try:
@ -283,18 +285,12 @@ class Sqlite3InMemoryTestDbs(unittest.TestCase):
}, },
}) })
other = db.connections['other'] other = db.connections['other']
self.assertEqual(other.features.supports_transactions, None) self.assertIsNone(other.features.supports_transactions)
DjangoTestSuiteRunner(verbosity=0).setup_databases() DjangoTestSuiteRunner(verbosity=0).setup_databases()
msg = "DATABASES setting '%s' option set to sqlite3's ':memory:' value shouldn't interfere with transaction support detection." % option
# Transaction support should be properly initialised for the 'other' DB # Transaction support should be properly initialised for the 'other' DB
self.assertNotEqual( self.assertIsNotNone(other.features.supports_transactions, msg)
other.features.supports_transactions,
None,
"DATABASES setting '%s' option set to sqlite3's ':memory:' value causes problems with transaction support detection." % option
)
# And all the DBs should report that they support transactions # And all the DBs should report that they support transactions
self.assertTrue( self.assertTrue(connections_support_transactions(), msg)
connections_support_transactions(),
"DATABASES setting '%s' option set to sqlite3's ':memory:' value causes problems with transaction support detection." % option
)
finally: finally:
db.connections = old_db_connections db.connections = old_db_connections