summaryrefslogtreecommitdiff
path: root/tests/check_framework
diff options
context:
space:
mode:
Diffstat (limited to 'tests/check_framework')
-rw-r--r--tests/check_framework/test_database.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/check_framework/test_database.py b/tests/check_framework/test_database.py
index bf291b24a1..6e6b4e3468 100644
--- a/tests/check_framework/test_database.py
+++ b/tests/check_framework/test_database.py
@@ -2,7 +2,7 @@ import unittest
from unittest import mock
from django.core.checks.database import check_database_backends
-from django.db import connection
+from django.db import connection, connections
from django.test import TestCase
@@ -18,6 +18,12 @@ class DatabaseCheckTests(TestCase):
@unittest.skipUnless(connection.vendor == 'mysql', 'Test only for MySQL')
def test_mysql_strict_mode(self):
+ def _clean_sql_mode():
+ for alias in self.databases:
+ if hasattr(connections[alias], 'sql_mode'):
+ del connections[alias].sql_mode
+
+ _clean_sql_mode()
good_sql_modes = [
'STRICT_TRANS_TABLES,STRICT_ALL_TABLES',
'STRICT_TRANS_TABLES',
@@ -29,6 +35,7 @@ class DatabaseCheckTests(TestCase):
return_value=(response,)
):
self.assertEqual(check_database_backends(databases=self.databases), [])
+ _clean_sql_mode()
bad_sql_modes = ['', 'WHATEVER']
for response in bad_sql_modes:
@@ -40,3 +47,4 @@ class DatabaseCheckTests(TestCase):
result = check_database_backends(databases=self.databases)
self.assertEqual(len(result), 2)
self.assertEqual([r.id for r in result], ['mysql.W002', 'mysql.W002'])
+ _clean_sql_mode()