Skip to content

Commit bff8a18

Browse files
committed
BUG#34710366: Django implementation does not pass unit tests
The Django unit tests implementation is not working as expected. The issues happen when using recent Django versions such as 4.1, 4.1.1 or 4.1.2. Changes integrated by these releases are breaking the current django unit tests implementation. With this patch some minor changes are made for Django unit tests code, hence restoring its correct functioning when used with Django v3 or v4. Change-Id: I87fba541cf93425b156629be95af862b5abab01f
1 parent 2ffc076 commit bff8a18

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ v8.0.32
1313

1414
- WL#15348: Support MIT Kerberos library on Windows
1515
- WL#15036: Support for type hints
16+
- BUG#34710366: Django implementation does not pass unit tests
1617
- BUG#34689812: Fix datetime conversion when using prepared cursors
1718
- BUG#34556157: Kerberos authorization fails when using SSPI as security interface
1819
- BUG#34499578: MySQLCursor.executemany() fails to correctly identify BULK data loading ops

tests/test_django.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@
5858
"ENGINE": "mysql.connector.django",
5959
"NAME": DBCONFIG["database"],
6060
"USER": "root",
61-
"PASSWORD": "",
61+
"PASSWORD": DBCONFIG.get("password", ""),
6262
"HOST": DBCONFIG["host"],
6363
"PORT": DBCONFIG["port"],
6464
"TEST_CHARSET": "utf8",
6565
"TEST_COLLATION": "utf8_general_ci",
6666
"CONN_MAX_AGE": 0,
6767
"AUTOCOMMIT": True,
6868
"TIME_ZONE": None,
69+
"CONN_HEALTH_CHECKS": False,
6970
},
7071
}
7172
settings.SECRET_KEY = "django_tests_secret_key"
@@ -131,6 +132,7 @@ class DjangoSettings(tests.MySQLConnectorTests):
131132
def test_get_connection_params(self):
132133
config = tests.get_mysql_config()
133134
settings_dict = connection.settings_dict.copy()
135+
settings_dict["OPTIONS"] = {}
134136

135137
# The default isolation_level should be None
136138
database_wrapper = DatabaseWrapper(settings_dict)
@@ -485,8 +487,6 @@ class CustomDjangoMySQLConverterTests(tests.MySQLConnectorTests):
485487

486488
@staticmethod
487489
def create_connection(alias=DEFAULT_DB_ALIAS):
488-
django.db.connections.ensure_defaults(alias)
489-
django.db.connections.prepare_test_settings(alias)
490490
db = django.db.connections.databases[alias]
491491
backend = load_backend(db["ENGINE"])
492492
return backend.DatabaseWrapper(db, alias)

0 commit comments

Comments
 (0)