Skip to content

Commit c45a495

Browse files
committed
More Python 3.8 fixes.
Also: -Split tests into separate pytest calls. - Combine coverage data to cater to split tests. - Reduced documentation test to juist one Python version. - Fix constraining versions of Django 2.2. - Separated requirements per framework.
1 parent 046ad0c commit c45a495

25 files changed

+89
-61
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"python": [
99
"2.7",
1010
"3.6",
11-
"3.7"
11+
"3.7",
12+
"3.8"
1213
],
1314
"cache": "pip",
1415
"install": [

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
sys.path.insert(0, os.path.abspath(".."))
2525
sys.path.insert(0, os.path.abspath("../src"))
2626

27-
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
27+
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.django.settings"
2828

2929
# -- General configuration ------------------------------------------------
3030

pytest.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[pytest]
2-
DJANGO_SETTINGS_MODULE = tests.settings
2+
DJANGO_SETTINGS_MODULE = tests.django.settings
33
norecursedirs = .git .*
4-
addopts = -rsxX --showlocals --tb=native --nomigrations --cov=dockerflow --cov-report xml --cov-report term --cov-report html
4+
addopts = -rsxX --showlocals --tb=native --cov=dockerflow --cov-report xml --cov-report term --cov-report html --cov-append
55
django_find_project = false
66
python_paths = .

tests/constraints/django-3.0.txt

Whitespace-only changes.
File renamed without changes.
File renamed without changes.

tests/django/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.

tests/test_django.py renamed to tests/django/test_django.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
from dockerflow.django import checks
1717
from dockerflow.django.middleware import DockerflowMiddleware
1818

19+
try:
20+
from django.utils.deprecation import MiddlewareMixin
21+
except ImportError: # pragma: no cover
22+
MiddlewareMixin = object
23+
1924

2025
@pytest.fixture
2126
def reset_checks():
@@ -57,8 +62,8 @@ def test_heartbeat(dockerflow_middleware, reset_checks, rf, settings):
5762
assert response.status_code == 200
5863

5964
settings.DOCKERFLOW_CHECKS = [
60-
"tests.django_checks.warning",
61-
"tests.django_checks.error",
65+
"tests.django.django_checks.warning",
66+
"tests.django.django_checks.error",
6267
]
6368
checks.register()
6469
response = dockerflow_middleware.process_request(request)
@@ -138,18 +143,21 @@ def test_request_summary_exception(
138143

139144

140145
def test_request_summary_failed_request(
141-
caplog, dockerflow_middleware, dockerflow_request
146+
admin_user, caplog, dockerflow_middleware, dockerflow_request
142147
):
143-
dockerflow_middleware.process_request(dockerflow_request)
144-
145-
class HostileMiddleware(object):
148+
class HostileMiddleware(MiddlewareMixin):
146149
def process_request(self, request):
147150
# simulating resetting request changes
148-
delattr(dockerflow_request, "_id")
149-
delattr(dockerflow_request, "_start_timestamp")
150-
return None
151+
delattr(request, "_id")
152+
delattr(request, "_start_timestamp")
151153

152-
response = HostileMiddleware().process_request(dockerflow_request)
154+
def process_response(self, request, response):
155+
return response
156+
157+
hostile_middleware = HostileMiddleware()
158+
response = dockerflow_middleware.process_request(dockerflow_request)
159+
response = hostile_middleware.process_request(dockerflow_request)
160+
response = hostile_middleware.process_response(dockerflow_request, response)
153161
dockerflow_middleware.process_response(dockerflow_request, response)
154162
assert len(caplog.records) == 1
155163
record = caplog.records[0]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/requirements.txt

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/requirements/default.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
4+
pytest
5+
pytest-coverage
6+
pytest-mock
7+
pytest-pythonpath
8+
mock
9+
redis<3.2.0
10+
fakeredis
11+
jsonschema

tests/requirements/django.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
django-redis
2+
pytest-django
3+
# these are constrained by the files in tests/constraints/*.txt
4+
# to support a triple stack Django/Flask/Sanic
5+
Django; python_version >= '3.0'
6+
Django<2.0; python_version < '3.0'

tests/requirements/docs.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Sphinx
2+
sphinxcontrib-httpdomain

tests/requirements/flask.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# these are constrained by the files in tests/constraints/*.txt
2+
# to support a triple stack Django/Flask/Sanic
3+
Flask
4+
Flask-Redis
5+
Flask-SQLAlchemy
6+
Flask-Login
7+
Flask-Migrate
8+
blinker

tests/requirements/lint.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
flake8
2+
flake8-black
3+
flake8-isort
4+
twine
5+
check-manifest

tests/requirements/sanic.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# these are constrained by the files in tests/constraints/*.txt
2+
# to support a triple stack Django/Flask/Sanic
3+
aiohttp
4+
aioredis
5+
Sanic
6+
sanic_redis
7+
uvloop>=0.14.0rc1
File renamed without changes.

tox.ini

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
usedevelop = True
33
minversion = 1.8
44
envlist =
5-
py36-lint,
6-
py36-dj{111,21,22}-docs,
5+
py38-lint,
6+
py36-docs,
77
# the version matrix according to the Django docs:
88
# https://docs.djangoproject.com/en/2.0/faq/install/#what-python-version-can-i-use-with-django
99
py{27,36}-dj111-tests,
10-
py{36,37,38}-dj{21,22}-tests,
11-
py{27,36}-fl{011,012,10}-tests,
10+
py{36,37}-dj{21,22}-tests,
11+
# py{36,37,38}-dj30-tests,
12+
py{27,36,37,38}-fl{011,012,10}-tests,
1213
py{36,37,38}-s19-tests,
1314

1415
[testenv]
@@ -18,33 +19,42 @@ basepython =
1819
py37: python3.7
1920
py38: python3.8
2021
usedevelop = true
22+
pip_pre = true
2123
setenv =
22-
DJANGO_SETTINGS_MODULE = tests.settings
24+
DJANGO_SETTINGS_MODULE = tests.django.settings
2325
PYTHONPATH = {toxinidir}
24-
# sanic integration requires python >= 3.5
25-
tests-py{27,34}: PYTEST_ADDOPTS = --ignore=tests/test_sanic.py
2626
deps =
27-
-rtests/requirements.txt
27+
-rtests/requirements/default.txt
28+
dj{111,21,22,30}: -rtests/requirements/django.txt
29+
fl{011,012,10}: -rtests/requirements/flask.txt
30+
s19: -rtests/requirements/sanic.txt
2831
dj111: -ctests/constraints/django-1.11.txt
2932
dj21: -ctests/constraints/django-2.1.txt
30-
dj21: -ctests/constraints/django-2.2.txt
33+
dj22: -ctests/constraints/django-2.2.txt
34+
# dj30: -ctests/constraints/django-3.0.txt
3135
fl011: -ctests/constraints/flask-0.11.txt
3236
fl012: -ctests/constraints/flask-0.12.txt
3337
fl10: -ctests/constraints/flask-1.0.txt
3438
s19: -ctests/constraints/sanic-19.txt
3539
commands =
3640
python --version
37-
tests: pytest {posargs:tests}
38-
docs: sphinx-build -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html
41+
dj{111,21,22,30}-tests: pytest tests/core/ tests/django --nomigrations {posargs:}
42+
fl{011,012,10}-tests: pytest tests/core/ tests/flask/ {posargs:}
43+
s19: pytest tests/core/ tests/sanic/
3944

40-
[testenv:py36-lint]
45+
[testenv:py36-docs]
4146
basepython = python3.6
4247
deps =
43-
flake8
44-
flake8-black
45-
flake8-isort
46-
twine
47-
check-manifest
48+
-rtests/requirements/default.txt
49+
-rtests/requirements/docs.txt
50+
-rtests/requirements/django.txt
51+
-rtests/requirements/flask.txt
52+
-rtests/requirements/sanic.txt
53+
commands = sphinx-build -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html
54+
55+
[testenv:py38-lint]
56+
basepython = python3.8
57+
deps = -rtests/requirements/lint.txt
4858
commands =
4959
flake8 src/dockerflow tests/
5060
check-manifest -v

0 commit comments

Comments
 (0)