Skip to content

Commit

Permalink
Merge pull request #666 from haricot/python36
Browse files Browse the repository at this point in the history
Add Support Python3.6
  • Loading branch information
jrief committed Oct 22, 2017
2 parents a268238 + 69eb092 commit 7c5a29a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ python:
- 2.7
- 3.4
- 3.5
- 3.6

env:
- DJANGOVER=django19
Expand All @@ -18,4 +19,5 @@ script:
- "if [[ $TRAVIS_PYTHON_VERSION == '2.7' && $DJANGOVER ]]; then export TOX_ENV=py27-$DJANGOVER; fi"
- "if [[ $TRAVIS_PYTHON_VERSION == '3.4' && $DJANGOVER ]]; then export TOX_ENV=py34-$DJANGOVER; fi"
- "if [[ $TRAVIS_PYTHON_VERSION == '3.5' && $DJANGOVER ]]; then export TOX_ENV=py35-$DJANGOVER; fi"
- "if [[ $TRAVIS_PYTHON_VERSION == '3.6' && $DJANGOVER ]]; then export TOX_ENV=py36-$DJANGOVER; fi"
- tox -r -e "$TOX_ENV"
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def convert(filename, fmt):
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
]
Expand Down
12 changes: 8 additions & 4 deletions shop/models/fields.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import enum
from enum import Enum, EnumMeta

from django.conf import settings
from django.db import models
from django.utils.six import python_2_unicode_compatible, with_metaclass, string_types
from django.utils.six import python_2_unicode_compatible, with_metaclass, string_types, PY2
from django.utils.translation import ugettext_lazy as _, ugettext


Expand All @@ -31,7 +31,7 @@ def deconstruct(self):
return name, path, args, kwargs


class ChoiceEnumMeta(enum.EnumMeta):
class ChoiceEnumMeta(EnumMeta):
def __new__(cls, name, bases, attrs):
new_class = super(ChoiceEnumMeta, cls).__new__(cls, name, bases, attrs)
values = [p.value for p in new_class.__members__.values()]
Expand All @@ -48,9 +48,13 @@ def __call__(cls, value, *args, **kwargs):
pass # let the super method complain
return super(ChoiceEnumMeta, cls).__call__(value, *args, **kwargs)

if PY2:
ENUM=with_metaclass(ChoiceEnumMeta, Enum)
else:
ENUM=Enum

@python_2_unicode_compatible
class ChoiceEnum(with_metaclass(ChoiceEnumMeta, enum.Enum)):
class ChoiceEnum(ENUM):
"""
Utility class to handle choices in Django model fields
"""
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = coverage-clean, py{27,34,35}-django{19,110}, coverage-report
envlist = coverage-clean, py{27,34,35,36}-django{19,110}, coverage-report

[testenv]
# usedevelop is needed to collect coverage data.
Expand All @@ -12,6 +12,7 @@ deps =
py27: -r{toxinidir}/requirements/test_py2.txt
py34: -r{toxinidir}/requirements/test_py3.txt
py35: -r{toxinidir}/requirements/test_py3.txt
py36: -r{toxinidir}/requirements/test_py3.txt
setenv =
DJANGO_SHOP_TUTORIAL = i18n_polymorphic
DJANGO_DEBUG = 1
Expand Down

0 comments on commit 7c5a29a

Please sign in to comment.