Toggle table of contents sidebar
Test Utilities¶The following can be imported from django_mysql.test.utils
.
Overrides MySQL system variables for a test method or for every test method in a class, similar to Django’s override_settings
. This can be useful when you’re testing code that must run under multiple MySQL environments (like most of django-mysql). For example:
@override_mysql_variables(SQL_MODE="MSSQL") class MyTests(TestCase): def test_it_works_in_mssql(self): run_it() @override_mysql_variables(SQL_MODE="ANSI") def test_it_works_in_ansi_mode(self): run_it()
During the first test, the SQL_MODE
will be MSSQL
, and during the second, it will be ANSI
; each slightly changes the allowed SQL syntax, meaning they are useful to test.
Note
This only sets the system variables for the session, so if the tested code closes and re-opens the database connection the change will be reset.
The connection alias to set the system variables for, defaults to ‘default’.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4