Skip to content

Commit

Permalink
Add django 1.8/1.9 compatibility. Drop unsupported django versions su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
kmmbvnr committed Jun 26, 2016
1 parent e4173dd commit 8b3995a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 131 deletions.
16 changes: 3 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ language: python
python:
- 2.7
- 3.4
- 3.5

env:
- DJANGO='Django>=1.3,<1.4'
- DJANGO='Django>=1.4,<1.5'
- DJANGO='Django>=1.5,<1.6'
- DJANGO='Django>=1.6,<1.7'
# - DJANGO='Django>=1.7,<1.8'
# - DJANGO='https://github.com/django/django/tarball/stable/1.8.x'
- DJANGO='Django>=1.8,<1.9'
- DJANGO='Django>=1.9,<1.10'

install:
- pip install --use-mirrors $DJANGO
Expand All @@ -19,10 +16,3 @@ install:
script: coverage run setup.py test

after_success: coveralls

matrix:
exclude:
- python: 3.4
env: DJANGO='Django>=1.3,<1.4'
- python: 3.4
env: DJANGO='Django>=1.4,<1.5'
1 change: 1 addition & 0 deletions parsley/tests/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class FormWithWidgets(forms.Form):
class StudentModelForm(forms.ModelForm):
class Meta:
model = Student
fields = '__all__'

def __init__(self, *args, **kwargs):
super(StudentModelForm, self).__init__(*args, **kwargs)
Expand Down
22 changes: 14 additions & 8 deletions parsley/widgets.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
class ParsleyChoiceFieldRendererMixin(object):
def __iter__(self):
for i, choice in enumerate(self.choices):
yield self[i]
def __init__(self, name, value, attrs, choices):
self.name = name
self.value = value
self.attrs = attrs
self._choices = choices

def __getitem__(self, idx):
choice = self.choices[idx]
if idx == len(self.choices) - 1:
self.attrs["{prefix}-required".format(prefix=self.parsley_namespace)] = "true"
return super(ParsleyChoiceFieldRendererMixin, self).__getitem__(idx)
@property
def choices(self):
def choices_iter():
choices_list = self._choices
for idx, choice in enumerate(choices_list):
if idx == len(choices_list) - 1:
self.attrs["{prefix}-required".format(prefix=self.parsley_namespace)] = "true"
yield choice
return choices_iter()
4 changes: 2 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
if hasattr(django, 'setup'):
django.setup()

from django.test.simple import DjangoTestSuiteRunner
from django.test.runner import DiscoverRunner


def runtests(*test_args, **kwargs):
if not test_args:
test_args = ['parsley']
parent = dirname(abspath(__file__))
sys.path.insert(0, parent)
test_runner = DjangoTestSuiteRunner(
test_runner = DiscoverRunner(
verbosity=kwargs.get('verbosity', 1),
interactive=kwargs.get('interactive', False),
failfast=kwargs.get('failfast'))
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def find_package_data(
"Framework :: Django",
],
zip_safe=False,
install_requires=["Django>=1.3,<=1.8"],
tests_require=["Django>=1.3,<=1.7", "six"],
install_requires=["Django>=1.8"],
tests_require=["Django>=1.8", "six"],
test_suite='runtests.runtests',
)
116 changes: 10 additions & 106 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,111 +1,15 @@
[tox]
envlist =
py26-1.3, py26-1.4, py26-1.5, py26-1.6,
py27-1.3, py27-1.4, py27-1.5, py27-1.6, py27-trunk,
py32-1.5, py32-1.6, py32-trunk,
py33-1.5, py33-1.6, py33-trunk,
envlist = py{27,34,35}-dj{18,19}
skipsdist = True


[testenv]
commands = coverage run -a setup.py test


[testenv:py26-1.3]
basepython = python2.6
deps =
django == 1.3.7
coverage == 3.6

[testenv:py26-1.4]
basepython = python2.6
deps =
django == 1.4.2
coverage == 3.6

[testenv:py26-1.5]
basepython = python2.6
deps =
django == 1.5
coverage == 3.6

[testenv:py26-1.6]
basepython = python2.6
deps =
https://github.com/django/django/tarball/stable/1.6.x
coverage == 3.6

[testenv:py26-trunk]
basepython = python2.6
deps =
https://github.com/django/django/tarball/master
coverage == 3.6


[testenv:py27-1.3]
basepython = python2.7
deps =
django == 1.3.7
coverage == 3.6

[testenv:py27-1.4]
basepython = python2.7
deps =
django == 1.4.2
coverage == 3.6

[testenv:py27-1.5]
basepython = python2.7
deps =
django == 1.5
coverage == 3.6

[testenv:py27-1.6]
basepython = python2.7
deps =
https://github.com/django/django/tarball/stable/1.6.x
coverage == 3.6

[testenv:py27-trunk]
basepython = python2.7
deps =
https://github.com/django/django/tarball/master
coverage == 3.6


[testenv:py32-1.5]
basepython = python3.2
deps =
django == 1.5
coverage == 3.6

[testenv:py32-1.6]
basepython = python3.2
deps =
https://github.com/django/django/tarball/stable/1.6.x
coverage == 3.6

[testenv:py32-trunk]
basepython = python3.2
deps =
https://github.com/django/django/tarball/master
coverage == 3.6



[testenv:py33-1.5]
basepython = python3.3
deps =
django == 1.5
coverage == 3.6

[testenv:py33-1.6]
basepython = python3.3
deps =
https://github.com/django/django/tarball/stable/1.6.x
coverage == 3.6

[testenv:py33-trunk]
basepython = python3.3
deps =
https://github.com/django/django/tarball/master
coverage == 3.6
basepython =
py27: python2.7
py34: python3.4
py35: python3.5
deps =
coverage>=4
dj18: django==1.8.13
dj19: django==1.9.7

0 comments on commit 8b3995a

Please sign in to comment.