Skip to content

Commit 546aada

Browse files
Surgomichaeljohnbarr
authored andcommitted
Add support for Django 2.1 and drop support for EOL versions. (#13)
* Add test for Django 2.1 and drop EOL versions (use tox to run tests) * Remove django-discover-runner * Fix duplication warning * Add changelogs and bump a version. * Add some metas. * Thank you @pjdelport :)
1 parent b9ddc12 commit 546aada

File tree

7 files changed

+102
-96
lines changed

7 files changed

+102
-96
lines changed

.travis.yml

Lines changed: 49 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,53 @@
1-
language:
2-
python
3-
4-
python:
5-
- "2.7"
6-
# https://docs.djangoproject.com/en/dev/releases/1.8/#python-compatibility
7-
# Due to the end of upstream support for Python 3.2 in February 2016, we
8-
# won’t test Django 1.8.x on Python 3.2 after the end of 2016.
9-
- "3.2"
10-
- "3.3"
11-
- "3.4"
12-
- "3.5"
13-
- "nightly"
14-
15-
env:
16-
- DJANGO="https://github.com/django/django/archive/master.tar.gz"
17-
- DJANGO="django>=2.0,<2.1"
18-
- DJANGO="django>=1.10,<1.11"
19-
- DJANGO="django>=1.9,<1.10"
20-
- DJANGO="django>=1.8,<1.9"
21-
1+
sudo: false
2+
language: python
3+
cache:
4+
pip: true
5+
directories:
6+
- $TRAVIS_BUILD_DIR/.tox
7+
matrix:
8+
fast_finish: true
9+
include:
10+
- env: TOX_ENV=py27-dj111
11+
python: 2.7
12+
- env: TOX_ENV=py34-dj111
13+
python: 3.4
14+
- env: TOX_ENV=py35-dj111
15+
python: 3.5
16+
- env: TOX_ENV=py36-dj111
17+
python: 3.6
18+
- env: TOX_ENV=py34-dj20
19+
python: 3.4
20+
- env: TOX_ENV=py35-dj20
21+
python: 3.5
22+
- env: TOX_ENV=py36-dj20
23+
python: 3.6
24+
- env: TOX_ENV=py37-dj20
25+
sudo: true # TODO Remove when supported
26+
dist: xenial
27+
python: 3.7
28+
- env: TOX_ENV=py35-dj21
29+
python: 3.5
30+
- env: TOX_ENV=py36-dj21
31+
python: 3.6
32+
- env: TOX_ENV=py37-dj21
33+
sudo: true # TODO Remove when supported
34+
dist: xenial
35+
python: 3.7
36+
- env: TOX_ENV=py35-djmaster
37+
python: 3.5
38+
- env: TOX_ENV=py36-djmaster
39+
python: 3.6
40+
- env: TOX_ENV=py37-djmaster
41+
sudo: true # TODO Remove when supported
42+
dist: xenial
43+
python: 3.7
44+
allow_failures:
45+
- env: TOX_ENV=py35-djmaster
46+
- env: TOX_ENV=py36-djmaster
47+
- env: TOX_ENV=py37-djmaster
2248
install:
23-
- travis_retry pip install $DJANGO
24-
- travis_retry pip install pytz
25-
- travis_retry pip install coverage==3.7.1 # required by python 3.2
26-
- travis_retry pip install coveralls
27-
- travis_retry pip install django-discover-runner
28-
49+
- pip install -U pip setuptools tox wheel
2950
script:
30-
- coverage run --source=timezone_utils run_tests.py
31-
- coverage report
32-
33-
after_success: coveralls
34-
51+
- tox -e "${TOX_ENV}"
3552
notifications:
3653
email: false
37-
38-
matrix:
39-
exclude:
40-
# https://docs.djangoproject.com/en/dev/releases/1.9/#python-compatibility
41-
# Django 1.9 requires Python 2.7, 3.4, or 3.5
42-
- python: "3.2"
43-
env: DJANGO="django>=1.9,<1.10"
44-
- python: "3.3"
45-
env: DJANGO="django>=1.9,<1.10"
46-
# https://docs.djangoproject.com/en/dev/releases/1.10/#python-compatibility
47-
# Django 1.10 requires Python 2.7, 3.4, or 3.5
48-
- python: "3.2"
49-
env: DJANGO="django>=1.10,<1.11"
50-
- python: "3.3"
51-
env: DJANGO="django>=1.10,<1.11"
52-
# https://docs.djangoproject.com/en/dev/releases/1.11/#python-compatibility
53-
# Django 1.11 requires Python 2.7, 3.4, or 3.5.
54-
# The Django 1.11.x series is the last to support Python 2.
55-
# The next major release, Django 2.0, will only support Python 3.5+
56-
- python: "2.7"
57-
env: DJANGO="django>=2.0,<2.1"
58-
- python: "3.2"
59-
env: DJANGO="django>=2.0,<2.1"
60-
- python: "3.3"
61-
env: DJANGO="django>=2.0,<2.1"
62-
- python: "3.2"
63-
env: DJANGO="https://github.com/django/django/archive/master.tar.gz"
64-
- python: "3.3"
65-
env: DJANGO="https://github.com/django/django/archive/master.tar.gz"
66-
allow_failures:
67-
- env: DJANGO="https://github.com/django/django/archive/master.tar.gz"
68-
- python: "nightly"
69-
fast_finish: true

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ Contributors
105105
* `Michael Barr <http://github.com/michaeljohnbarr>`_
106106
* `Kosei Kitahara <https://github.com/Surgo>`_
107107
* `Alex Kamedov <https://github.com/alekam>`_
108+
* `Pi Delport <https://github.com/pjdelport>`_
108109

109110
Changelog
110111
---------
112+
- 0.12 Add support for Django 2.1. Support Python 3.7. Drop support for Django 1.8.
111113
- 0.11 Removed reference to django.db.models.fields.subclassing.SubfieldBase, which means that only Django 1.8+ is now supported. Removed support for Python versions < 2.6. The Django 1.6 series was the last to support Python 2.6. Added testing support for Django 1.10. Changed development status from Beta to Production/Stable.
112114
- 0.10 Added testing support for Python 3.5 and Django 1.9.
113115
- 0.9 Corrected a bug to where ``time_override`` caused invalid date due to not converting to the correct timezone first. Refactored conversion code. Added testing support for Django 1.8. Removed Django from setup requirements - the onus of having a supported version of Django is on the developer.

run_tests.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import sys
88

99
# Django
10-
from django import VERSION
1110
from django.conf import settings
1211
from django.core.management import execute_from_command_line
1312
from django.utils import timezone
@@ -21,11 +20,6 @@
2120

2221
if not settings.configured:
2322
test_runners_args = {}
24-
if VERSION < (1, 6): # pragma: no cover
25-
INSTALLED_APPS.append('discover_runner')
26-
test_runners_args = {
27-
'TEST_RUNNER': 'discover_runner.DiscoverRunner',
28-
}
2923
settings.configure(
3024
DATABASES={
3125
'default': {
@@ -50,7 +44,6 @@
5044
datetime(2014, 1, 1), pytz.timezone('UTC')
5145
),
5246
# SILENCED_SYSTEM_CHECKS=['1_7.W001'],
53-
**test_runners_args
5447
)
5548

5649

setup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@
2121
packages=['timezone_utils'],
2222
install_requires=[
2323
'pytz',
24-
'django>=1.8'
24+
'django>=1.11'
2525
],
2626
zip_safe=False,
2727
platforms='any',
2828
include_package_data=True,
2929
classifiers=[
3030
'Development Status :: 5 - Production/Stable',
31+
'Environment :: Web Environment',
3132
'Framework :: Django',
33+
'Framework :: Django :: 1.11',
34+
'Framework :: Django :: 2.0',
35+
'Framework :: Django :: 2.1',
3236
'Intended Audience :: Developers',
3337
'License :: OSI Approved :: MIT License',
3438
'Natural Language :: English',
@@ -37,10 +41,10 @@
3741
'Programming Language :: Python :: 2',
3842
'Programming Language :: Python :: 2.7',
3943
'Programming Language :: Python :: 3',
40-
'Programming Language :: Python :: 3.2',
41-
'Programming Language :: Python :: 3.3',
4244
'Programming Language :: Python :: 3.4',
4345
'Programming Language :: Python :: 3.5',
46+
'Programming Language :: Python :: 3.6',
47+
'Programming Language :: Python :: 3.7',
4448
'Topic :: Database',
4549
'Topic :: Software Development :: Libraries',
4650
],

timezone_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = (0, 11)
1+
__version__ = (0, 12)
22
VERSION = '.'.join(map(str, __version__))

timezone_utils/fields.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def from_db_value(self, value, expression, connection, context): # noqa
9393
the reverse of get_prep_value(). - New in Django 1.8
9494
"""
9595
if value:
96-
value = self.to_python(value)
96+
return self.to_python(value)
9797
return value
9898
else:
9999
def from_db_value(self, value, expression, connection):
@@ -102,7 +102,7 @@ def from_db_value(self, value, expression, connection):
102102
the reverse of get_prep_value(). - New in Django 1.8
103103
"""
104104
if value:
105-
value = self.to_python(value)
105+
return self.to_python(value)
106106
return value
107107

108108
def to_python(self, value):
@@ -242,12 +242,26 @@ def __init__(self, *args, **kwargs):
242242

243243
super(LinkedTZDateTimeField, self).__init__(*args, **kwargs)
244244

245-
def from_db_value(self, value, expression, connection, context):
246-
# pylint: disable=W0613
247-
if value:
248-
value = self.to_python(value)
249-
250-
return value
245+
# Django 2.0 updates the signature of from_db_value.
246+
# https://docs.djangoproject.com/en/2.0/releases/2.0/#context-argument-of-field-from-db-value-and-expression-convert-value
247+
if django.VERSION < (2,):
248+
def from_db_value(self, value, expression, connection, context): # noqa
249+
"""
250+
Converts a value as returned by the database to a Python object. It is
251+
the reverse of get_prep_value(). - New in Django 1.8
252+
"""
253+
if value:
254+
return self.to_python(value)
255+
return value
256+
else:
257+
def from_db_value(self, value, expression, connection):
258+
"""
259+
Converts a value as returned by the database to a Python object. It is
260+
the reverse of get_prep_value(). - New in Django 1.8
261+
"""
262+
if value:
263+
return self.to_python(value)
264+
return value
251265

252266
def to_python(self, value):
253267
"""Convert the value to the appropriate timezone."""

tox.ini

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
# tox (https://tox.readthedocs.io/) is a tool for running tests
2-
# in multiple virtualenvs. This configuration file will run the
3-
# test suite on all supported python versions. To use it, "pip install tox"
4-
# and then run "tox" from this directory.
5-
61
[tox]
2+
skipsdist = true
3+
skip_missing_interpreters = true
74
envlist =
8-
py{27,34,35,36}-dj1.{8,11}
9-
py{34,35,36}-dj2.0
10-
5+
py{27,34,35,36}-dj111,
6+
py{34,35,36,37}-dj20,
7+
py{35,36,37}-dj21,
8+
py{35,36,37}-djmaster
119
[testenv]
10+
basepython =
11+
py27: python2.7
12+
py34: python3.4
13+
py35: python3.5
14+
py36: python3.6
15+
py37: python3.7
1216
deps =
13-
dj1.8: Django ~=1.8.0
14-
dj1.11: Django ~=1.11.0
15-
dj2.0: Django ~=2.0.0
17+
dj111: Django>=1.11,<2.0
18+
dj20: Django>=2.0,<2.1
19+
dj21: Django>=2.1,<2.2
20+
djmaster: https://github.com/django/django/archive/master.tar.gz
21+
py37-dj21: codecov
22+
pytz
23+
coverage
1624
commands =
17-
{envpython} run_tests.py
25+
coverage run --source=timezone_utils run_tests.py
26+
py37-dj21: codecov

0 commit comments

Comments
 (0)