Skip to content

Commit 99281d6

Browse files
committed
Attempt testing against MySQL.
1 parent ef1e239 commit 99281d6

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
dist: trusty
22
sudo: false
33
language: python
4+
services:
5+
- mysql
46
env:
57
- TOXENV=flake8
68
- TOXENV=isort
@@ -10,6 +12,8 @@ matrix:
1012
include:
1113
- python: 2.7
1214
env: TOXENV=py27-1.11
15+
- python: 2.7
16+
env: TOXENV=py27-1.11-mysql DATABASE_BACKEND=mysql DATABASE_NAME=test
1317
- python: 3.4
1418
env: TOXENV=py34-1.11
1519
- python: 3.4

sundial/fields.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ def from_db_value(self, value, expression, connection, context=None):
9595
return value
9696

9797
if settings.USE_TZ and not connection.features.supports_timezones:
98-
# At this point the value will be in the connection's timezone
99-
# even if it's actually stored using self.db_timezone.
100-
# Strip the bogus timezone assignment, make it aware in the
101-
# appropriate timezone, and convert it it back to UTC.
102-
value = timezone.make_aware(value.replace(tzinfo=None), self.db_tzinfo).astimezone(timezone.utc)
98+
# At this point the value will be in UTC even if the actual field's
99+
# timezone is self.db_timezone. Replace the bogus timezone with the
100+
# appropriate one and convert back to the expected UTC.
101+
value = timezone.make_aware(
102+
value.replace(tzinfo=None), self.db_tzinfo
103+
).astimezone(timezone.utc)
103104

104105
return value

tests/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from __future__ import unicode_literals
22

3+
import os
4+
35
SECRET_KEY = 'not-anymore'
46

57
TIME_ZONE = 'America/Chicago'
68

79
DATABASES = {
810
'default': {
9-
'ENGINE': 'django.db.backends.sqlite3',
11+
'ENGINE': 'django.db.backends.%s' % os.environ.get('DATABASE_BACKEND', 'sqlite3'),
12+
'NAME': os.environ.get('DATABASE_NAME', ':memory:')
1013
}
1114
}
1215

tox.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ envlist =
55
flake8,
66
isort,
77
py27-1.11,
8+
py27-1.11-mysql,
89
py34-{1.11,2.0},
910
py35-{1.11,2.0,2.1,master},
1011
py36-{1.11,2.0,2.1,master},
1112
py37-{2.0,2.1,master}
1213

1314
[testenv]
15+
passenv = DATABASE_*
16+
setenv =
17+
mysql: DATABASE_BACKEND=mysql
1418
basepython =
1519
py27: python2.7
1620
py34: python3.4
@@ -27,6 +31,7 @@ deps =
2731
2.0: Django>=2.0,<2.1
2832
2.1: Django>=2.1,<2.2
2933
master: https://github.com/django/django/archive/master.tar.gz
34+
mysql: mysqlclient<1.4
3035

3136
[testenv:flake8]
3237
usedevelop = false

0 commit comments

Comments
 (0)