Skip to content

Commit

Permalink
Attempt testing against MySQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
charettes committed Jan 20, 2019
1 parent ef1e239 commit 99281d6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
dist: trusty
sudo: false
language: python
services:
- mysql
env:
- TOXENV=flake8
- TOXENV=isort
Expand All @@ -10,6 +12,8 @@ matrix:
include:
- python: 2.7
env: TOXENV=py27-1.11
- python: 2.7
env: TOXENV=py27-1.11-mysql DATABASE_BACKEND=mysql DATABASE_NAME=test
- python: 3.4
env: TOXENV=py34-1.11
- python: 3.4
Expand Down
11 changes: 6 additions & 5 deletions sundial/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ def from_db_value(self, value, expression, connection, context=None):
return value

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

return value
5 changes: 4 additions & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import unicode_literals

import os

SECRET_KEY = 'not-anymore'

TIME_ZONE = 'America/Chicago'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'ENGINE': 'django.db.backends.%s' % os.environ.get('DATABASE_BACKEND', 'sqlite3'),
'NAME': os.environ.get('DATABASE_NAME', ':memory:')
}
}

Expand Down
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ envlist =
flake8,
isort,
py27-1.11,
py27-1.11-mysql,
py34-{1.11,2.0},
py35-{1.11,2.0,2.1,master},
py36-{1.11,2.0,2.1,master},
py37-{2.0,2.1,master}

[testenv]
passenv = DATABASE_*
setenv =
mysql: DATABASE_BACKEND=mysql
basepython =
py27: python2.7
py34: python3.4
Expand All @@ -27,6 +31,7 @@ deps =
2.0: Django>=2.0,<2.1
2.1: Django>=2.1,<2.2
master: https://github.com/django/django/archive/master.tar.gz
mysql: mysqlclient<1.4

[testenv:flake8]
usedevelop = false
Expand Down

0 comments on commit 99281d6

Please sign in to comment.