Skip to content

Commit 4e8a238

Browse files
authored
Merge pull request #212 from luzfcb/patch-1
fix compatibility of test suit with django 1.10
2 parents 8469dd6 + b963009 commit 4e8a238

9 files changed

+122
-70
lines changed

.travis.yml

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,50 @@
11
language: python
22
services: sqlite
3-
env:
4-
- DJANGO='django>=1.5,<1.6'
5-
- DJANGO='django>=1.6,<1.7'
6-
- DJANGO='django>=1.7,<1.8'
7-
- DJANGO='django>=1.8,<1.9'
8-
- DJANGO='django>=1.9,<1.10'
9-
python:
10-
- 3.5
11-
- 3.4
12-
- 3.3
13-
- 3.2
14-
- 2.7
15-
install:
16-
- pip install $DJANGO
17-
- python setup.py install
18-
- pip install factory_boy mock pytest-django
19-
script: py.test tests/
3+
cache:
4+
directories:
5+
- $HOME/.cache/pip
6+
before_cache:
7+
- rm -f $HOME/.cache/pip/log/debug.log
208
matrix:
21-
exclude:
22-
- python: 3.2
23-
env: DJANGO='django>=1.8,<1.9'
24-
- python: 3.2
25-
env: DJANGO='django>=1.9,<1.10'
26-
- python: 3.3
27-
env: DJANGO='django>=1.8,<1.9'
28-
- python: 3.3
29-
env: DJANGO='django>=1.9,<1.10'
30-
- python: 3.4
31-
env: DJANGO='django>=1.4,<1.5'
32-
- python: 3.5
33-
env: DJANGO='django>=1.5,<1.6'
34-
- python: 3.5
35-
env: DJANGO='django>=1.6,<1.7'
36-
- python: 3.5
37-
env: DJANGO='django>=1.7,<1.8'
9+
include:
10+
- python: 2.7
11+
env: TOX_ENV=py27-django15
12+
- python: 2.7
13+
env: TOX_ENV=py27-django16
14+
- python: 2.7
15+
env: TOX_ENV=py27-django17
16+
- python: 2.7
17+
env: TOX_ENV=py27-django18
18+
- python: 3.3
19+
env: TOX_ENV=py33-django15
20+
- python: 3.3
21+
env: TOX_ENV=py33-django16
22+
- python: 3.3
23+
env: TOX_ENV=py33-django17
24+
- python: 3.3
25+
env: TOX_ENV=py33-django18
26+
- python: 3.4
27+
env: TOX_ENV=py34-django15
28+
- python: 3.4
29+
env: TOX_ENV=py34-django16
30+
- python: 3.4
31+
env: TOX_ENV=py34-django17
32+
- python: 3.4
33+
env: TOX_ENV=py34-django18
34+
- python: 3.4
35+
env: TOX_ENV=py34-django19
36+
- python: 3.4
37+
env: TOX_ENV=py34-django110
38+
- python: 3.5
39+
env: TOX_ENV=py35-django18
40+
- python: 3.5
41+
env: TOX_ENV=py35-django19
42+
- python: 3.5
43+
env: TOX_ENV=py35-django110
44+
45+
46+
script: tox -e $TOX_ENV
47+
48+
install:
49+
- pip install pip setuptools wheel -U
50+
- pip install tox

CONTRIBUTORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Direct Contributors
2929
* Lacey Williams Henschel
3030
* Gregory Shikhman
3131
* Mike Bryant
32+
* Fabio C. Barrionuevo da Luz
3233

3334
Other Contributors
3435
==================

docs/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ Tests
4242
-----
4343

4444
All code changes should come with test changes. We use
45-
`py.test <https://pypi.python.org/pypi/pytest/2.5.2>`_ instead of Python's
45+
`py.test <https://pypi.python.org/pypi/pytest>`_ instead of Python's
4646
``unittest``. This seems to only be really important when marking tests for
4747
skipping.
4848

4949
We try to keep the project at 100% test coverage but know this isn't something
5050
we can achieve forever. So long as your tests cover your contribution 80% or
5151
better, we're happy to try and bump up that last bit, or just accept the code.
5252

53-
We currently test Braces against late (usually latest) versions of Python 2.6, 2.7, 3.2, 3.3, and 3.4. We also test against the latest released version of Django from 1.5 to 1.8.
53+
We currently test Braces against late (usually latest) versions of Python 2.7, 3.2, 3.3, 3.4 and 3.5. We also test against the latest released version of Django from 1.5 to 1.10.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"Development Status :: 5 - Production/Stable",
2424
"Programming Language :: Python :: 2.6",
2525
"Programming Language :: Python :: 2.7",
26-
"Programming Language :: Python :: 3.2",
2726
"Programming Language :: Python :: 3.3",
2827
"Programming Language :: Python :: 3.4",
2928
"Programming Language :: Python :: 3.5",
@@ -32,6 +31,7 @@
3231
"Framework :: Django :: 1.6",
3332
"Framework :: Django :: 1.7",
3433
"Framework :: Django :: 1.8",
35-
"Framework :: Django :: 1.9"
34+
"Framework :: Django :: 1.9",
35+
"Framework :: Django :: 1.10"
3636
],
3737
)

tests/compat.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@
99
from django.utils import simplejson as json
1010

1111
try:
12-
from django.conf.urls import patterns, url, include
12+
from django.conf.urls import url, include
1313
except ImportError:
14-
from django.conf.urls.defaults import patterns, url, include
14+
from django.conf.urls.defaults import url, include
15+
16+
17+
def patterns_compat(urlpatterns):
18+
try:
19+
from django.conf.urls import patterns
20+
except ImportError:
21+
try:
22+
from django.conf.urls.defaults import patterns
23+
except ImportError:
24+
patterns = False
25+
if patterns:
26+
return patterns(
27+
'', *urlpatterns
28+
)
29+
else:
30+
return urlpatterns

tests/settings.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@
2929
'django.middleware.clickjacking.XFrameOptionsMiddleware',
3030
]
3131

32-
TEMPLATE_CONTEXT_PROCESSORS = [
33-
'django.contrib.auth.context_processors.auth',
34-
'django.core.context_processors.i18n',
35-
'django.core.context_processors.media',
36-
'django.core.context_processors.static',
37-
'django.core.context_processors.tz',
38-
'django.core.context_processors.request',
39-
'django.contrib.messages.context_processors.messages'
40-
]
41-
4232
STATICFILES_FINDERS = (
4333
'django.contrib.staticfiles.finders.FileSystemFinder',
4434
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
@@ -60,6 +50,40 @@
6050
)
6151

6252
import django
53+
54+
if django.VERSION >= (1, 10):
55+
TEMPLATES = [
56+
{
57+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
58+
'DIRS': [],
59+
'APP_DIRS': True,
60+
'OPTIONS': {
61+
'context_processors': [
62+
'django.template.context_processors.debug',
63+
'django.template.context_processors.request',
64+
'django.contrib.auth.context_processors.auth',
65+
'django.template.context_processors.i18n',
66+
'django.template.context_processors.media',
67+
'django.template.context_processors.static',
68+
'django.template.context_processors.tz',
69+
'django.contrib.messages.context_processors.messages',
70+
],
71+
},
72+
},
73+
]
74+
AUTH_PASSWORD_VALIDATORS = []
75+
76+
else:
77+
TEMPLATE_CONTEXT_PROCESSORS = [
78+
'django.contrib.auth.context_processors.auth',
79+
'django.core.context_processors.i18n',
80+
'django.core.context_processors.media',
81+
'django.core.context_processors.static',
82+
'django.core.context_processors.tz',
83+
'django.core.context_processors.request',
84+
'django.contrib.messages.context_processors.messages'
85+
]
86+
6387
if django.VERSION < (1, 4):
6488
TEMPLATE_CONTEXT_PROCESSORS.remove('django.core.context_processors.tz')
6589
MIDDLEWARE_CLASSES.remove(

tests/urls.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from __future__ import absolute_import
22

3+
from django.contrib.auth.views import login
34
from . import views
4-
from .compat import patterns, include, url
5+
from .compat import include, url, patterns_compat
56

6-
7-
urlpatterns = patterns(
8-
'',
7+
urlpatterns = [
98
# LoginRequiredMixin tests
109
url(r'^login_required/$', views.LoginRequiredView.as_view()),
1110

@@ -110,12 +109,11 @@
110109
# RecentLoginRequiredMixin tests
111110
url(r'^recent_login/$', views.RecentLoginRequiredView.as_view()),
112111
url(r'^outdated_login/$', views.RecentLoginRequiredView.as_view()),
113-
)
112+
]
114113

114+
urlpatterns += [
115+
url(r'^accounts/login/$', login, {'template_name': 'blank.html'}),
116+
url(r'^auth/login/$', login, {'template_name': 'blank.html'}),
117+
]
115118

116-
urlpatterns += patterns(
117-
'django.contrib.auth.views',
118-
# login page, required by some tests
119-
url(r'^accounts/login/$', 'login', {'template_name': 'blank.html'}),
120-
url(r'^auth/login/$', 'login', {'template_name': 'blank.html'}),
121-
)
119+
urlpatterns = patterns_compat(urlpatterns)

tests/urls_namespaced.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from __future__ import absolute_import
22

33
from . import views
4-
from .compat import patterns, url
4+
from .compat import url, patterns_compat
55

6-
7-
urlpatterns = patterns(
8-
'',
6+
urlpatterns = [
97
# CanonicalSlugDetailMixin namespace tests
108
url(r'^article/(?P<pk>\d+)-(?P<slug>[\w-]+)/$',
119
views.CanonicalSlugDetailView.as_view(),
1210
name="namespaced_article"),
13-
)
11+
]
12+
13+
urlpatterns = patterns_compat(urlpatterns)

tox.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
[tox]
2-
envlist = py{27,32,33,34}-django{15,16,17,18},py{27,34,35}-django{18,19}
2+
envlist = py{27,33,34}-django{15,16,17,18},py{34,35}-django{18,19,110}
33
install_command = pip install {opts} {packages}
44

55
[testenv]
66
basepython =
77
py27: python2.7
8-
py32: python3.2
98
py33: python3.3
109
py34: python3.4
1110
py35: python3.5
@@ -17,13 +16,14 @@ commands =
1716

1817
deps =
1918
mock
20-
pytest-django
2119
factory_boy
22-
py32: coverage==3.7
20+
py{27,33,34}: pytest-django==2.9.1
21+
py{35}: pytest-django>2.9.1
2322
py{27,33,34,35}: coverage==4.1
2423
argparse
2524
django15: Django>=1.5,<1.6
2625
django16: Django>=1.6,<1.7
2726
django17: Django>=1.7,<1.8
2827
django18: Django>=1.8,<1.9
2928
django19: Django>=1.9,<1.10
29+
django110: Django>=1.10,<1.11

0 commit comments

Comments
 (0)