Skip to content

Commit

Permalink
Merge branch 'develop': release 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mfogel committed Mar 1, 2018
2 parents d23add1 + de89760 commit 19bd65c
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 58 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
.coverage
.tox
*.pyc
*.egg-info
htmlcov
46 changes: 13 additions & 33 deletions .travis.yml
@@ -1,40 +1,20 @@
sudo: false
language: python
matrix:
include:
- python: "2.7"
env: TOXENV=flake8
- python: "2.7"
env: TOXENV=coverage
install: pip install tox coveralls
after_success: coveralls
- python: "2.7"
env: TOXENV=py27-django18-sqlite
- python: "2.7"
env: TOXENV=py27-django18-postgres
- python: "2.7"
env: TOXENV=py27-django19-sqlite
- python: "2.7"
env: TOXENV=py27-django19-postgres
- python: "3.4"
env: TOXENV=py34-django18-sqlite
- python: "3.4"
env: TOXENV=py34-django18-postgres
- python: "3.4"
env: TOXENV=py34-django19-sqlite
- python: "3.4"
env: TOXENV=py34-django19-postgres
- python: "3.5"
env: TOXENV=py35-django18-sqlite
- python: "3.5"
env: TOXENV=py35-django18-postgres
- python: "3.5"
env: TOXENV=py35-django19-sqlite
- python: "3.5"
env: TOXENV=py35-django19-postgres

python:
- 2.7
- 3.4
- 3.5
- 3.6

install:
- pip install tox
- pip install tox-travis coveralls

before_script:
- psql -c 'create database timezone_field_tests;' -U postgres

script:
- tox

after_success:
- coveralls
9 changes: 9 additions & 0 deletions README.rst
Expand Up @@ -83,6 +83,13 @@ Installation
Changelog
------------

* 2.1 (2018-03-01)

* Add support for django 1.10, 1.11
* Add support for python 3.6
* Add wheel support
* Support bytes in DB fields (`#38`__ & `#39`__)

* 2.0 (2016-01-31)

* Drop support for django 1.7, add support for django 1.9
Expand Down Expand Up @@ -146,6 +153,8 @@ __ http://pypi.python.org/pypi/pytz/
__ http://pypi.python.org/pypi/django-timezone-field/
__ http://www.pip-installer.org/
__ https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
__ https://github.com/mfogel/django-timezone-field/issues/38
__ https://github.com/mfogel/django-timezone-field/issues/39
__ https://github.com/mfogel/django-timezone-field/issues?q=milestone%3A1.3
__ https://tox.readthedocs.org/
__ https://github.com/mfogel/django-timezone-field/
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -48,6 +48,7 @@ def find_version(*file_paths):
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Utilities',
'Framework :: Django',
],
Expand Down
2 changes: 0 additions & 2 deletions tests/settings.py
Expand Up @@ -50,8 +50,6 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'tests.urls'

WSGI_APPLICATION = 'tests.wsgi.application'


Expand Down
10 changes: 10 additions & 0 deletions tests/tests.py
Expand Up @@ -289,6 +289,7 @@ class TimeZoneFieldDeconstructTestCase(TestCase):

test_fields = (
TimeZoneField(),
TimeZoneField(default='UTC'),
TimeZoneField(max_length=42),
TimeZoneField(choices=[
(pytz.timezone('US/Pacific'), 'US/Pacific'),
Expand Down Expand Up @@ -316,6 +317,15 @@ def test_full_serialization(self):
# ensuring the following call doesn't throw an error
MigrationWriter.serialize(field)

def test_from_db_value(self):
"""
Verify that the field can handle data coming back as bytes from the
db.
"""
field = TimeZoneField()
value = field.from_db_value(b'UTC', None, None, None)
self.assertEqual(pytz.UTC, value)

def test_default_kwargs_not_frozen(self):
"""
Ensure the deconstructed representation of the field does not contain
Expand Down
2 changes: 1 addition & 1 deletion timezone_field/__init__.py
@@ -1,5 +1,5 @@
from timezone_field.fields import TimeZoneField
from timezone_field.forms import TimeZoneFormField

__version__ = '2.0'
__version__ = '2.1'
__all__ = ['TimeZoneField', 'TimeZoneFormField']
10 changes: 5 additions & 5 deletions timezone_field/fields.py
Expand Up @@ -3,6 +3,7 @@
from django.core.exceptions import ValidationError
from django.db import models
from django.utils import six
from django.utils.encoding import force_text

from timezone_field.utils import is_pytz_instance

Expand Down Expand Up @@ -109,9 +110,8 @@ def _get_python_and_db_repr(self, value):
return (None, '')
if is_pytz_instance(value):
return (value, value.zone)
if isinstance(value, six.string_types):
try:
return (pytz.timezone(value), value)
except pytz.UnknownTimeZoneError:
pass
try:
return (pytz.timezone(force_text(value)), force_text(value))
except pytz.UnknownTimeZoneError:
pass
raise ValidationError("Invalid timezone '%s'" % value)
36 changes: 19 additions & 17 deletions tox.ini
@@ -1,35 +1,37 @@
[tox]
envlist =
{py27,py34,py35}-django{18,19}-{sqlite,postgres},
flake8, coverage
coverage-clean,
py27-{django18,django19,django110,django111}-{sqlite,postgres},
py34-{django18,django19,django110,django111}-{sqlite,postgres},
py35-{django18,django19,django110,django111}-{sqlite,postgres},
py36-django111-{sqlite,postgres},
coverage-report,
flake8

[testenv]
basepython =
py27: python2.7
py34: python3.4
py35: python3.5
commands = coverage run --include='*/timezone_field/*' {envbindir}/django-admin.py test tests
deps =
coverage
django18: django>=1.8,<1.9
django19: django>=1.9,<1.10
postgres: psycopg2
django110: django>=1.10,<1.11
django111: django>=1.11,<2.0
postgres: psycopg2-binary
setenv =
PYTHONPATH = {toxinidir}
DJANGO_SETTINGS_MODULE=tests.settings
sqlite: TEST_DB_ENGINE=sqlite
postgres: TEST_DB_ENGINE=postgres
commands = {envbindir}/django-admin.py test tests

[testenv:flake8]
basepython = python2.7
commands = flake8
deps = flake8
commands = {envbindir}/flake8 {toxinidir}/timezone_field

[testenv:coverage]
basepython = python2.7
[testenv:coverage-clean]
commands = coverage erase

[testenv:coverage-report]
commands =
coverage erase
coverage run --include='*/timezone_field/*' {envbindir}/django-admin.py test tests
deps =
coverage
django>=1.8,<1.9
psycopg2
coverage report
coverage html

0 comments on commit 19bd65c

Please sign in to comment.