mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #26541 -- Allowed MySQL transaction detection to work without table creation.
This commit is contained in:
committed by
Tim Graham
parent
fa2f55cfd5
commit
6e4e0f4ce4
@@ -1,8 +1,25 @@
|
||||
from unittest import skipUnless
|
||||
|
||||
from django.db import connection
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, mock
|
||||
|
||||
|
||||
class TestDatabaseFeatures(TestCase):
|
||||
|
||||
def test_nonexistent_feature(self):
|
||||
self.assertFalse(hasattr(connection.features, 'nonexistent'))
|
||||
|
||||
|
||||
@skipUnless(connection.vendor == 'mysql', 'MySQL backend tests')
|
||||
class TestMySQLFeatures(TestCase):
|
||||
|
||||
def test_mysql_supports_transactions(self):
|
||||
"""
|
||||
All storage engines except MyISAM support transactions.
|
||||
"""
|
||||
with mock.patch('django.db.connection.features._mysql_storage_engine', 'InnoDB'):
|
||||
self.assertTrue(connection.features.supports_transactions)
|
||||
del connection.features.supports_transactions
|
||||
with mock.patch('django.db.connection.features._mysql_storage_engine', 'MyISAM'):
|
||||
self.assertFalse(connection.features.supports_transactions)
|
||||
del connection.features.supports_transactions
|
||||
|
||||
Reference in New Issue
Block a user