summaryrefslogtreecommitdiff
path: root/tests/check_framework/test_database.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/check_framework/test_database.py')
-rw-r--r--tests/check_framework/test_database.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/check_framework/test_database.py b/tests/check_framework/test_database.py
index 6e6b4e3468..c9bc8866e7 100644
--- a/tests/check_framework/test_database.py
+++ b/tests/check_framework/test_database.py
@@ -29,20 +29,22 @@ class DatabaseCheckTests(TestCase):
'STRICT_TRANS_TABLES',
'STRICT_ALL_TABLES',
]
- for response in good_sql_modes:
- with mock.patch(
- 'django.db.backends.utils.CursorWrapper.fetchone', create=True,
- return_value=(response,)
+ for sql_mode in good_sql_modes:
+ with mock.patch.object(
+ connection, 'mysql_server_data', {'sql_mode': sql_mode},
):
self.assertEqual(check_database_backends(databases=self.databases), [])
_clean_sql_mode()
bad_sql_modes = ['', 'WHATEVER']
- for response in bad_sql_modes:
- with mock.patch(
- 'django.db.backends.utils.CursorWrapper.fetchone', create=True,
- return_value=(response,)
- ):
+ for sql_mode in bad_sql_modes:
+ mocker_default = mock.patch.object(
+ connection, 'mysql_server_data', {'sql_mode': sql_mode},
+ )
+ mocker_other = mock.patch.object(
+ connections['other'], 'mysql_server_data', {'sql_mode': sql_mode},
+ )
+ with mocker_default, mocker_other:
# One warning for each database alias
result = check_database_backends(databases=self.databases)
self.assertEqual(len(result), 2)