Skip to content

Commit a4a5393

Browse files
authored
Merge pull request #1121 from matthiask/mariadb
Run tests with MariaDB
2 parents e78ac8c + 48a0e2e commit a4a5393

File tree

5 files changed

+38
-16
lines changed

5 files changed

+38
-16
lines changed

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ matrix:
3737
env: TOXENV=postgresql
3838
addons:
3939
postgresql: "9.5"
40+
- python: 3.7
41+
env: TOXENV=mariadb
42+
addons:
43+
mariadb: "10.3"
4044
- env: TOXENV=flake8
4145
- python: 3.7
4246
env: TOXENV=style

tests/models.py

+5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
from __future__ import absolute_import, unicode_literals
44

5+
from django.db import models
56
from django.utils import six
67

78

89
class NonAsciiRepr(object):
910
def __repr__(self):
1011
return "nôt åscíì" if six.PY3 else "nôt åscíì".encode("utf-8")
12+
13+
14+
class Binary(models.Model):
15+
field = models.BinaryField()

tests/panels/test_sql.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,26 @@ def test_param_conversion(self):
113113
('["Foo", true, false]', "[10, 1]", '["2017-12-22 16:07:01"]'),
114114
)
115115

116-
@unittest.skipIf(
117-
connection.vendor in ("sqlite", "postgresql"),
118-
"Mixing bytestrings and text is not allowed on PostgreSQL and SQLite",
119-
)
120116
def test_binary_param_force_text(self):
121117
self.assertEqual(len(self.panel._queries), 0)
122118

123119
with connection.cursor() as cursor:
124-
cursor.execute("SELECT * FROM auth_user WHERE username = %s", [b"\xff"])
120+
cursor.execute(
121+
"SELECT * FROM tests_binary WHERE field = %s",
122+
[connection.Database.Binary(b"\xff")],
123+
)
125124

126125
self.panel.process_response(self.request, self.response)
127126
self.panel.generate_stats(self.request, self.response)
128127

129128
self.assertEqual(len(self.panel._queries), 1)
130-
self.assertEqual(
131-
self.panel._queries[0][1]["sql"],
132-
"SELECT * FROM auth_user WHERE username = '\ufffd'",
129+
self.assertTrue(
130+
self.panel._queries[0][1]["sql"].startswith(
131+
(
132+
"<strong>SELECT</strong> * <strong>FROM</strong>"
133+
" tests_binary <strong>WHERE</strong> field = "
134+
)
135+
)
133136
)
134137

135138
@unittest.skipUnless(connection.vendor != "sqlite", "Test invalid for SQLite")

tests/settings.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,8 @@
8585
"default": {"ENGINE": "django.db.backends.postgresql", "NAME": "debug-toolbar"}
8686
}
8787
elif os.environ.get("DJANGO_DATABASE_ENGINE") == "mysql":
88-
# % mysql
89-
# CREATE USER 'debug_toolbar'@'localhost' IDENTIFIED BY '';
90-
# GRANT ALL PRIVILEGES ON debug_toolbar.* TO 'test_debug_toolbar'@'localhost';
9188
DATABASES = {
92-
"default": {
93-
"ENGINE": "django.db.backends.mysql",
94-
"NAME": "debug_toolbar",
95-
"USER": "debug_toolbar",
96-
}
89+
"default": {"ENGINE": "django.db.backends.mysql", "NAME": "debug_toolbar"}
9790
}
9891
else:
9992
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3"}}

tox.ini

+17
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ envlist =
55
py{35,36,37}-dj21
66
py{35,36,37}-djmaster
77
postgresql,
8+
mariadb,
89
flake8,
910
style,
1011
readme
@@ -42,6 +43,22 @@ whitelist_externals = make
4243
pip_pre = True
4344
commands = make coverage TEST_ARGS='{posargs:tests}'
4445

46+
[testenv:mariadb]
47+
deps =
48+
Django>=2.1,<2.2
49+
coverage
50+
django_jinja
51+
html5lib
52+
mysqlclient
53+
selenium<4.0
54+
sqlparse
55+
setenv =
56+
PYTHONPATH = {toxinidir}
57+
DJANGO_DATABASE_ENGINE = mysql
58+
whitelist_externals = make
59+
pip_pre = True
60+
commands = make coverage TEST_ARGS='{posargs:tests}'
61+
4562
[testenv:flake8]
4663
basepython = python3
4764
commands = make flake8

0 commit comments

Comments
 (0)