Skip to content

Commit

Permalink
Merge pull request #212 from luzfcb/patch-1
Browse files Browse the repository at this point in the history
fix compatibility of test suit with django 1.10
  • Loading branch information
kennethlove authored Oct 24, 2016
2 parents 8469dd6 + b963009 commit 4e8a238
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 70 deletions.
81 changes: 47 additions & 34 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
language: python
services: sqlite
env:
- DJANGO='django>=1.5,<1.6'
- DJANGO='django>=1.6,<1.7'
- DJANGO='django>=1.7,<1.8'
- DJANGO='django>=1.8,<1.9'
- DJANGO='django>=1.9,<1.10'
python:
- 3.5
- 3.4
- 3.3
- 3.2
- 2.7
install:
- pip install $DJANGO
- python setup.py install
- pip install factory_boy mock pytest-django
script: py.test tests/
cache:
directories:
- $HOME/.cache/pip
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
matrix:
exclude:
- python: 3.2
env: DJANGO='django>=1.8,<1.9'
- python: 3.2
env: DJANGO='django>=1.9,<1.10'
- python: 3.3
env: DJANGO='django>=1.8,<1.9'
- python: 3.3
env: DJANGO='django>=1.9,<1.10'
- python: 3.4
env: DJANGO='django>=1.4,<1.5'
- python: 3.5
env: DJANGO='django>=1.5,<1.6'
- python: 3.5
env: DJANGO='django>=1.6,<1.7'
- python: 3.5
env: DJANGO='django>=1.7,<1.8'
include:
- python: 2.7
env: TOX_ENV=py27-django15
- python: 2.7
env: TOX_ENV=py27-django16
- python: 2.7
env: TOX_ENV=py27-django17
- python: 2.7
env: TOX_ENV=py27-django18
- python: 3.3
env: TOX_ENV=py33-django15
- python: 3.3
env: TOX_ENV=py33-django16
- python: 3.3
env: TOX_ENV=py33-django17
- python: 3.3
env: TOX_ENV=py33-django18
- python: 3.4
env: TOX_ENV=py34-django15
- python: 3.4
env: TOX_ENV=py34-django16
- python: 3.4
env: TOX_ENV=py34-django17
- python: 3.4
env: TOX_ENV=py34-django18
- python: 3.4
env: TOX_ENV=py34-django19
- python: 3.4
env: TOX_ENV=py34-django110
- python: 3.5
env: TOX_ENV=py35-django18
- python: 3.5
env: TOX_ENV=py35-django19
- python: 3.5
env: TOX_ENV=py35-django110


script: tox -e $TOX_ENV

install:
- pip install pip setuptools wheel -U
- pip install tox
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Direct Contributors
* Lacey Williams Henschel
* Gregory Shikhman
* Mike Bryant
* Fabio C. Barrionuevo da Luz

Other Contributors
==================
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ Tests
-----

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

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

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.
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.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
Expand All @@ -32,6 +31,7 @@
"Framework :: Django :: 1.6",
"Framework :: Django :: 1.7",
"Framework :: Django :: 1.8",
"Framework :: Django :: 1.9"
"Framework :: Django :: 1.9",
"Framework :: Django :: 1.10"
],
)
20 changes: 18 additions & 2 deletions tests/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@
from django.utils import simplejson as json

try:
from django.conf.urls import patterns, url, include
from django.conf.urls import url, include
except ImportError:
from django.conf.urls.defaults import patterns, url, include
from django.conf.urls.defaults import url, include


def patterns_compat(urlpatterns):
try:
from django.conf.urls import patterns
except ImportError:
try:
from django.conf.urls.defaults import patterns
except ImportError:
patterns = False
if patterns:
return patterns(
'', *urlpatterns
)
else:
return urlpatterns
44 changes: 34 additions & 10 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

TEMPLATE_CONTEXT_PROCESSORS = [
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages'
]

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
Expand All @@ -60,6 +50,40 @@
)

import django

if django.VERSION >= (1, 10):
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
},
},
]
AUTH_PASSWORD_VALIDATORS = []

else:
TEMPLATE_CONTEXT_PROCESSORS = [
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages'
]

if django.VERSION < (1, 4):
TEMPLATE_CONTEXT_PROCESSORS.remove('django.core.context_processors.tz')
MIDDLEWARE_CLASSES.remove(
Expand Down
20 changes: 9 additions & 11 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from __future__ import absolute_import

from django.contrib.auth.views import login
from . import views
from .compat import patterns, include, url
from .compat import include, url, patterns_compat


urlpatterns = patterns(
'',
urlpatterns = [
# LoginRequiredMixin tests
url(r'^login_required/$', views.LoginRequiredView.as_view()),

Expand Down Expand Up @@ -110,12 +109,11 @@
# RecentLoginRequiredMixin tests
url(r'^recent_login/$', views.RecentLoginRequiredView.as_view()),
url(r'^outdated_login/$', views.RecentLoginRequiredView.as_view()),
)
]

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

urlpatterns += patterns(
'django.contrib.auth.views',
# login page, required by some tests
url(r'^accounts/login/$', 'login', {'template_name': 'blank.html'}),
url(r'^auth/login/$', 'login', {'template_name': 'blank.html'}),
)
urlpatterns = patterns_compat(urlpatterns)
10 changes: 5 additions & 5 deletions tests/urls_namespaced.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from __future__ import absolute_import

from . import views
from .compat import patterns, url
from .compat import url, patterns_compat


urlpatterns = patterns(
'',
urlpatterns = [
# CanonicalSlugDetailMixin namespace tests
url(r'^article/(?P<pk>\d+)-(?P<slug>[\w-]+)/$',
views.CanonicalSlugDetailView.as_view(),
name="namespaced_article"),
)
]

urlpatterns = patterns_compat(urlpatterns)
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[tox]
envlist = py{27,32,33,34}-django{15,16,17,18},py{27,34,35}-django{18,19}
envlist = py{27,33,34}-django{15,16,17,18},py{34,35}-django{18,19,110}
install_command = pip install {opts} {packages}

[testenv]
basepython =
py27: python2.7
py32: python3.2
py33: python3.3
py34: python3.4
py35: python3.5
Expand All @@ -17,13 +16,14 @@ commands =

deps =
mock
pytest-django
factory_boy
py32: coverage==3.7
py{27,33,34}: pytest-django==2.9.1
py{35}: pytest-django>2.9.1
py{27,33,34,35}: coverage==4.1
argparse
django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11

0 comments on commit 4e8a238

Please sign in to comment.