From dba1f5965878f1503cacb0f723761d7437e9d7f4 Mon Sep 17 00:00:00 2001 From: Fabre Florian Date: Fri, 26 Apr 2019 04:50:07 +0200 Subject: [PATCH] Add tox targets for Django 2.2 & master. Add coverage & flake8 validation. Fix templatetags test view. --- .travis.yml | 56 ++++-------------- README.rst | 4 ++ .../templatetags/user_agents.py | 2 +- django_user_agents/tests/__init__.py | 4 +- django_user_agents/tests/tests.py | 3 + django_user_agents/tests/views.py | 2 +- setup.py | 3 +- tox.ini | 57 ++++++++++++++++--- 8 files changed, 72 insertions(+), 59 deletions(-) diff --git a/.travis.yml b/.travis.yml index f85f02e..36353ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,50 +7,16 @@ python: - "3.5" - "3.6" - "3.7" -env: - - DJANGO="django>=1.8,<1.9" - - DJANGO="django>=1.9,<1.10" - - DJANGO="django>=1.10,<1.11" - - DJANGO="django>=1.11,<2.0" - - DJANGO="django>=2.0,<2.1" - - DJANGO="django>=2.1,<2.2" install: - - "pip install user-agents" - - "pip install ${DJANGO}" -script: - - "python manage.py test" -matrix: - exclude: - - python: "2.7" - env: DJANGO="django>=2.0,<2.1" - - python: "2.7" - env: DJANGO="django>=2.1,<2.2" - - python: "3.4" - env: DJANGO="django>=2.1,<2.2" - - python: "3.6" - env: DJANGO="django>=1.8,<1.9" - - python: "3.6" - env: DJANGO="django>=1.9,<1.10" - - python: "3.6" - env: DJANGO="django>=1.10,<1.11" - - python: "3.7" - env: DJANGO="django>=1.8,<1.9" - - python: "3.7" - env: DJANGO="django>=1.9,<1.10" - - python: "3.7" - env: DJANGO="django>=1.10,<1.11" - - python: "3.7" - env: DJANGO="django>=1.11,<2.0" + - pip install user-agents + - pip install tox tox-travis +jobs: include: - - python: "pypy" - env: DJANGO="django>=1.8,<1.9" - dist: trusty - - python: "pypy" - env: DJANGO="django>=1.9,<1.10" - dist: trusty - - python: "pypy" - env: DJANGO="django>=1.10,<1.11" - dist: trusty - - python: "pypy" - env: DJANGO="django>=1.11,<2.0" - dist: trusty + - stage: lint + python: "3.6" + script: tox -e flake8 + - stage: test + script: tox + - stage: coverage + python: "3.6" + script: tox -e coverage diff --git a/README.rst b/README.rst index 972ab32..3408c3e 100644 --- a/README.rst +++ b/README.rst @@ -155,6 +155,10 @@ Running Tests Changelog ========= +unreleased +---------- +* Add support for Django 2.0 to 2.2 + 0.3.1 ----- * Fixed a bug when request have no META attribute diff --git a/django_user_agents/templatetags/user_agents.py b/django_user_agents/templatetags/user_agents.py index 12be297..385e03a 100644 --- a/django_user_agents/templatetags/user_agents.py +++ b/django_user_agents/templatetags/user_agents.py @@ -28,4 +28,4 @@ def is_bot(request): @register.filter() def is_touch_capable(request): - return get_and_set_user_agent(request).is_touch_capable \ No newline at end of file + return get_and_set_user_agent(request).is_touch_capable diff --git a/django_user_agents/tests/__init__.py b/django_user_agents/tests/__init__.py index 5712886..c48937d 100644 --- a/django_user_agents/tests/__init__.py +++ b/django_user_agents/tests/__init__.py @@ -1 +1,3 @@ -from .tests import MiddlewareTest \ No newline at end of file +from .tests import MiddlewareTest + +__all__ = ['MiddlewareTest'] diff --git a/django_user_agents/tests/tests.py b/django_user_agents/tests/tests.py index 508e012..2c52ec2 100644 --- a/django_user_agents/tests/tests.py +++ b/django_user_agents/tests/tests.py @@ -60,6 +60,9 @@ def test_filters_can_be_loaded_in_template(self): client = Client(HTTP_USER_AGENT=ipad_ua_string) response = client.get(reverse('user_agent_test_filters')) self.assertEqual(response.status_code, 200) + self.assertContains( + response, + 'Just making sure all the filters can be used without errors') def test_filters(self): request = RequestFactory(HTTP_USER_AGENT=iphone_ua_string).get('') diff --git a/django_user_agents/tests/views.py b/django_user_agents/tests/views.py index d2b5f2e..94e361c 100644 --- a/django_user_agents/tests/views.py +++ b/django_user_agents/tests/views.py @@ -6,4 +6,4 @@ def test(request): def test_filters(request): - return render(request, "test.html", {'request': request}) \ No newline at end of file + return render(request, "test_filters.html", {'request': request}) diff --git a/setup.py b/setup.py index 7a036f3..bb4694f 100644 --- a/setup.py +++ b/setup.py @@ -31,11 +31,10 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Internet :: WWW/HTTP', diff --git a/tox.ini b/tox.ini index 5211bad..d504ebe 100644 --- a/tox.ini +++ b/tox.ini @@ -1,24 +1,63 @@ [tox] -envlist = py{27,34,35,36}-django{18,19,110,111}, +envlist = flake8, + py{27,34,35,36}-django{18,19,110,111}, py{34}-django{20}, - py{35,36,37}-django{20,21} + py{35,36,37}-django{20,21,22} + py{36,37}-djangomaster, + coverage install_command = pip install {opts} {packages} [testenv] -basepython = - py27: python2.7 - py34: python3.4 - py35: python3.5 - py36: python3.6 - py37: python3.7 deps = -e. + flake8: flake8 django18: Django>=1.8,<1.9 django19: Django>=1.9,<1.10 django110: Django>=1.10,<1.11 django111: Django>=1.11,<2.0 django20: Django>=2.0,<2.1 django21: Django>=2.1,<2.2 + django22: Django>=2.2,<3.0 + djangomaster: https://github.com/django/django/archive/master.tar.gz commands = - python -Wd manage.py test + python -Wd manage.py test {posargs} + +[tox:travis] +2.7 = py27 +3.4 = py34 +3.5 = py35 +3.6 = py36 +3.7 = py37 + +[travis:env] +DJANGO = + 1.8: django18 + 1.9: django19 + 1.10: django110 + 1.11: django111 + 2.0: django20 + 2.1: django21 + 2.2: django22 + master: djangomaster + +[testenv:coverage] +basepython = python3.6 +deps = + coverage + Django>=2.2,<3.0 +commands = + python -Wd {envbindir}/coverage run --source=django_user_agents --omit=*/tests/* manage.py test {posargs} + coverage report -m + +[testenv:py36-djangomaster] +ignore_outcome=true + +[testenv:py37-djangomaster] +ignore_outcome=true + +[testenv:flake8] +basepython = python2.7 +deps = + flake8 +commands = flake8 django_user_agents --ignore=E501