2017-01-19 17:16:04 +00:00
|
|
|
from unittest import mock, skipUnless
|
2016-09-29 19:05:35 +00:00
|
|
|
|
2015-09-14 16:19:19 +00:00
|
|
|
from django.db import connection
|
2017-01-19 17:16:04 +00:00
|
|
|
from django.test import TestCase
|
2015-09-14 16:19:19 +00:00
|
|
|
|
|
|
|
|
2017-02-11 20:37:49 +00:00
|
|
|
@skipUnless(connection.vendor == 'mysql', 'MySQL tests')
|
|
|
|
class TestFeatures(TestCase):
|
2015-09-14 16:19:19 +00:00
|
|
|
|
2017-02-11 20:37:49 +00:00
|
|
|
def test_supports_transactions(self):
|
2016-09-29 19:05:35 +00:00
|
|
|
"""
|
|
|
|
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
|