From 1a45062ecc93e3bf9dcc5297b7d62ee25bef53f2 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 27 Jul 2017 14:15:36 -0500 Subject: [PATCH 1/8] update urls for django 1.8+ in tests --- tests/urls.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/urls.py b/tests/urls.py index 739c5dd..0d0a5b4 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -try: - from django.conf.urls.defaults import patterns, url -except ImportError: - from django.conf.urls import patterns, url +from django.conf.urls import url from django.http import HttpResponse from django.shortcuts import render @@ -21,8 +18,7 @@ def jinja_template_view(request): return render(request, 'jinja.html', {}) -urlpatterns = patterns( - '', +urlpatterns = [ url(r'^$', view), url(r'^template/django/$', djnago_template_view), url(r'^template/jinja/$', jinja_template_view), @@ -31,4 +27,4 @@ def jinja_template_view(request): url(r'^menu/submenu/$', view), url(r'^страница/$', view), url(r'^другая_страница/$', view, name='non-ascii-reverse') -) +] From 91ada875ede27fa1d3eb86c3f85139a9cc0e307b Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 27 Jul 2017 14:17:08 -0500 Subject: [PATCH 2/8] add testserver to ALLOWED_HOSTS --- tests/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/__init__.py b/tests/__init__.py index 372c537..52e179a 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -7,6 +7,7 @@ config = dict( + ALLOWED_HOSTS=['testserver'], DEBUG=True, DATABASES={ 'default': { From ee3bfb420e7f3bf24ec025fd31de9fc0c1253873 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 27 Jul 2017 14:18:30 -0500 Subject: [PATCH 3/8] add new tox.ini from django-extensions (MIT) --- tox.ini | 101 +++++++++++++++----------------------------------------- 1 file changed, 26 insertions(+), 75 deletions(-) diff --git a/tox.ini b/tox.ini index 8ba1b8c..a78c139 100644 --- a/tox.ini +++ b/tox.ini @@ -1,87 +1,38 @@ +# Tox (http://tox.testrun.org/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. +# Based off of django-extensions tox.ini, license MIT +# https://github.com/django-extensions/django-extensions/blob/master/LICENSE + [tox] envlist = - py2-flake8, - py2-frosted, - py2-isort, - py3-flake8, - py3-frosted, - py3-isort, - py26-dj{13,14}, - py27-dj{13,14,15,16,17,18,19}, - py32-dj{15,16,17,18}, - py33-dj{15,16,17,18}, - py34-dj{15,16,17,18,19}, - py35-dj{19}, - py36-dj{19,110,110,111}, - pypy-dj{13,14,15,16,17,18,19,110,111} + {py27,py34,py35,py36}-flake8 + {py27,py33,py34,py36,pypy,pypy3}-dj18 + {py27,py34,py35,py36,pypy}-dj{dj110,dj111,master} [testenv] -basepython = - py2: python2 - py3: python3 - py26: python2.6 - py27: python2.7 - py32: python3.2 - py33: python3.3 - py34: python3.4 - py35: python3.5 - py36: python3.6 - pypy: pypy -commands = - {envpython} setup.py nosetests -deps = - py32: jinja2<2.7 - py{2,3,26,27,33,34,35,36,py}: jinja2 - dj13: django>=1.3,<1.4 - dj14: django>=1.4,<1.5 - dj15: django>=1.5,<1.6 - dj16: django>=1.6,<1.7 - dj17: django>=1.7,<1.8 - dj18: django>=1.8,<1.9 - dj19: django>=1.9,<1.10 - dj110: django>=1.10,<1.11 - dj111: django>=1.11,<1.12 - isort: isort - nose +commands = {envpython} setup.py nosetests +whitelist_externals = make -[testenv:py2-flake8] deps = - flake8 - flake8-blind-except - flake8-debugger - flake8-print - flake8-quotes - pep8-naming -commands = - flake8 --show-source django_activeurl + dj18: Django>=1.8,<1.9 + dj110: Django>=1.10,<1.11 + dj111: Django>=1.11b1,<1.12 + djmaster: https://github.com/django/django/archive/master.tar.gz + nose==1.3.7 -[testenv:py2-frosted] +[testenv:py27-flake8] deps = - frosted -commands = - frosted -r django_activeurl + flake8 +commands = flake8 django_activeurl tests -[testenv:py2-isort] -commands = - isort --check-only -rc django_activeurl --diff - -[testenv:py3-flake8] +[testenv:py34-flake8] deps = - flake8 - flake8-blind-except - flake8-debugger - flake8-print - flake8-quotes - pep8-naming -commands = - flake8 --show-source django_activeurl + flake8 +commands = flake8 django_activeurl tests -[testenv:py3-frosted] +[testenv:py35-flake8] deps = - frosted -commands = - frosted -r django_activeurl - -[testenv:py3-isort] -commands = - isort --check-only -rc django_activeurl --diff + flake8 +commands = flake8 django_activeurl tests From c7f2ee3f132592149613cde96edd5885d5aa62be Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 27 Jul 2017 14:20:19 -0500 Subject: [PATCH 4/8] add .travis.yml from django-extensions (MIT) --- .travis.yml | 132 ++++++++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 61 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4117ad7..b48284f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,66 +1,76 @@ -sudo: false language: python -python: - - "3.6" - - "3.5" - - "3.4" - - "3.3" - - "2.7" - - "2.6" - - "pypy" -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="django>=1.8,<1.9" - - DJANGO="django>=1.9,<1.10" - - DJANGO="django>=1.10,<1.11" - - DJANGO="django>=1.11,<1.12" + +sudo: false + matrix: - exclude: - - python: "3.5" - env: DJANGO="django>=1.3,<1.4" - - python: "3.5" - 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" - - python: "3.5" - env: DJANGO="django>=1.8,<1.9" - - python: "3.4" - env: DJANGO="django>=1.3,<1.4" - - python: "3.4" - env: DJANGO="django>=1.4,<1.5" - - python: "3.3" - env: DJANGO="django>=1.3,<1.4" - - python: "3.3" - env: DJANGO="django>=1.4,<1.5" - - python: "3.3" - env: DJANGO="https://github.com/django/django/tarball/stable/1.9.x#egg=django" - - python: "2.6" - env: DJANGO="django>=1.5,<1.6" - - python: "2.6" - env: DJANGO="django>=1.6,<1.7" - - python: "2.6" - env: DJANGO="django>=1.7,<1.8" - - python: "2.6" - env: DJANGO="django>=1.8,<1.9" - - python: "2.6" - env: DJANGO="https://github.com/django/django/tarball/stable/1.9.x#egg=django" + fast_finish: true + include: + - python: 2.7 + env: TOXENV=py27-flake8 + - python: 3.4 + env: TOXENV=py34-flake8 + - python: 3.5 + env: TOXENV=py35-flake8 + - python: 3.6 + env: TOXENV=py36-flake8 + - python: 2.7 + env: TOXENV=py27-dj18 + - python: 2.7 + env: TOXENV=py27-dj110 + - python: 2.7 + env: TOXENV=py27-dj111 + - python: 3.3 + env: TOXENV=py33-dj18 + - python: 3.4 + env: TOXENV=py34-dj18 + - python: 3.4 + env: TOXENV=py34-dj110 + - python: 3.4 + env: TOXENV=py34-dj111 + - python: 3.5 + env: TOXENV=py35-dj18 + - python: 3.5 + env: TOXENV=py35-dj110 + - python: 3.5 + env: TOXENV=py35-dj111 + - python: 3.5 + env: TOXENV=py35-djmaster + - python: 3.6 + env: TOXENV=py36-dj18 + - python: 3.6 + env: TOXENV=py36-dj110 + - python: 3.6 + env: TOXENV=py36-dj111 + - python: 3.6 + env: TOXENV=py36-djmaster + - python: pypy + env: TOXENV=pypy-dj18 + - python: pypy + env: TOXENV=pypy-dj110 + - python: pypy + env: TOXENV=pypy-dj111 + - python: pypy3.5-5.8.0 + env: TOXENV=pypy3-dj18 + - python: pypy3.5-5.8.0 + env: TOXENV=pypy3-dj110 + - python: pypy3.5-5.8.0 + env: TOXENV=pypy3-djmaster + + allow_failures: + - python: 3.5 + env: TOXENV=py35-djmaster + - python: 3.6 + env: TOXENV=py36-djmaster + - python: pypy3.5-5.8.0 + env: TOXENV=pypy3-dj110 + - python: pypy3.5-5.8.0 + env: TOXENV=pypy3-djmaster + install: - - travis_retry pip install --upgrade pip -q - - travis_retry pip install $DJANGO - - travis_retry pip install lxml django-classy-tags django_appconf jinja2 -q - - travis_retry pip install nose coverage flake8 flake8-blind-except flake8-debugger flake8-print flake8-quotes pep8-naming frosted isort coveralls -q + - pip install virtualenv tox coveralls + script: - - python setup.py nosetests --with-coverage + - tox + after_success: - - flake8 --show-source django_activeurl - - frosted -r django_activeurl - - isort --check-only -rc django_activeurl --dif - - travis_retry coveralls + - coveralls From 8045c256df0f2201b8c9a5b089934fd37834f52c Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 27 Jul 2017 14:38:14 -0500 Subject: [PATCH 5/8] add isort to new travis/tox tests --- .travis.yml | 4 ++++ tox.ini | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/.travis.yml b/.travis.yml index b48284f..ce8086f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,10 @@ matrix: env: TOXENV=py35-flake8 - python: 3.6 env: TOXENV=py36-flake8 + - python: 2.7 + env: TOXENV=py27-isort + - python: 3.6 + env: TOXENV=py36-isort - python: 2.7 env: TOXENV=py27-dj18 - python: 2.7 diff --git a/tox.ini b/tox.ini index a78c139..498f47e 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,7 @@ [tox] envlist = + isort {py27,py34,py35,py36}-flake8 {py27,py33,py34,py36,pypy,pypy3}-dj18 {py27,py34,py35,py36,pypy}-dj{dj110,dj111,master} @@ -36,3 +37,13 @@ commands = flake8 django_activeurl tests deps = flake8 commands = flake8 django_activeurl tests + +[testenv:py27-isort] +deps = + isort +commands = isort --check-only -rc django_activeurl --diff + +[testenv:py36-isort] +deps = + isort +commands = isort --check-only -rc django_activeurl --diff From 07595ff87ef82d531ac607287dc939861d99bf70 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 27 Jul 2017 15:01:13 -0500 Subject: [PATCH 6/8] change nose -> pytest --- setup.py | 19 ++++++++++++++++++- tests/{tests.py => test_activeurl.py} | 0 tox.ini | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) rename tests/{tests.py => test_activeurl.py} (100%) diff --git a/setup.py b/setup.py index 7ebea56..da99dd2 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,28 @@ +import sys from io import open from setuptools import setup +from setuptools.command.test import test as TestCommand + about = {} with open("django_activeurl/__about__.py", encoding='utf-8') as fp: exec(fp.read(), about) +class PyTest(TestCommand): + user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] + + def initialize_options(self): + TestCommand.initialize_options(self) + self.pytest_args = [] + + def run_tests(self): + import pytest + errno = pytest.main(self.pytest_args) + sys.exit(errno) + + classifiers = '''\ Framework :: Django Environment :: Web Environment @@ -71,5 +87,6 @@ def long_description(): classifiers=list(filter(None, classifiers.split('\n'))), keywords=[ 'django', 'url', 'link', 'active', 'css', 'templatetag', 'jinja2' - ] + ], + cmdclass={'test': PyTest}, ) diff --git a/tests/tests.py b/tests/test_activeurl.py similarity index 100% rename from tests/tests.py rename to tests/test_activeurl.py diff --git a/tox.ini b/tox.ini index 498f47e..565544f 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,7 @@ envlist = {py27,py34,py35,py36,pypy}-dj{dj110,dj111,master} [testenv] -commands = {envpython} setup.py nosetests +commands = {envpython} setup.py test whitelist_externals = make deps = @@ -21,7 +21,7 @@ deps = dj110: Django>=1.10,<1.11 dj111: Django>=1.11b1,<1.12 djmaster: https://github.com/django/django/archive/master.tar.gz - nose==1.3.7 + pytest==3.1.3 [testenv:py27-flake8] deps = From fb2eb57651d0236e66c51f45589493f09d2a74e0 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 27 Jul 2017 16:38:41 -0500 Subject: [PATCH 7/8] sort imports --- django_activeurl/utils.py | 2 +- tests/jinja_config.py | 3 ++- tests/test_activeurl.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/django_activeurl/utils.py b/django_activeurl/utils.py index 3b0149a..2fec6f6 100644 --- a/django_activeurl/utils.py +++ b/django_activeurl/utils.py @@ -3,8 +3,8 @@ from django.core.cache import cache from django.utils.http import urlquote -from django.utils.translation import get_language from django.utils.six.moves.urllib import parse as urlparse +from django.utils.translation import get_language from lxml.etree import ParserError from lxml.html import fragment_fromstring, tostring diff --git a/tests/jinja_config.py b/tests/jinja_config.py index 5b0f2ed..8e579e4 100644 --- a/tests/jinja_config.py +++ b/tests/jinja_config.py @@ -1,7 +1,8 @@ from django.core.urlresolvers import reverse +from jinja2 import Environment + from django_activeurl.ext.django_jinja import ActiveUrl from django_activeurl.ext.utils import options as activeurl_options -from jinja2 import Environment def environment(**options): diff --git a/tests/test_activeurl.py b/tests/test_activeurl.py index 750c60d..b227253 100644 --- a/tests/test_activeurl.py +++ b/tests/test_activeurl.py @@ -3,8 +3,8 @@ import django from django.core.cache import cache -from django.template import Template, Context -from django.test.client import RequestFactory, Client +from django.template import Context, Template +from django.test.client import Client, RequestFactory from django.utils.translation import get_language from lxml.html import fragment_fromstring, fromstring From 5742b9df37d1e39863dd791e427eb47d01ef1fe2 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 27 Jul 2017 17:05:39 -0500 Subject: [PATCH 8/8] allow pypy3 + dj 1.8 to fail --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ce8086f..3718200 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,6 +65,8 @@ matrix: env: TOXENV=py35-djmaster - python: 3.6 env: TOXENV=py36-djmaster + - python: pypy3.5-5.8.0 + env: TOXENV=pypy3-dj18 - python: pypy3.5-5.8.0 env: TOXENV=pypy3-dj110 - python: pypy3.5-5.8.0