Adds a tox.ini file and instructions in the readme for how to use it.

This commit is contained in:
Robert Wells 2020-05-16 13:41:45 -07:00
parent a63a13ea05
commit 0bc943ff25
8 changed files with 58 additions and 7 deletions

View File

@ -51,6 +51,21 @@ The easiest way to run test coverage is with [`coverage`](https://pypi.org/proje
which runs the tests against all supported Django installs. To run the test coverage which runs the tests against all supported Django installs. To run the test coverage
within a virtualenv, run `coverage run ./runtests.py` from the repository directory then run `coverage report`. within a virtualenv, run `coverage run ./runtests.py` from the repository directory then run `coverage report`.
#### Tox
Testing may also be done using [`tox`](https://pypi.org/project/tox/), which
will run the tests against all supported combinations of python and django.
Install tox, either globally or within a virtualenv, and then simply run `tox`
from the repository directory. As there are many combinations, you may run them
in [`parallel`](https://tox.readthedocs.io/en/latest/config.html#cmdoption-tox-p)
using `tox --parallel`.
The `tox.ini` includes an environment for testing code [`coverage`](https://pypi.org/project/coverage/)
and you can run it and view this report with `tox -e coverage`.
Linting may also be performed via [`flake8`](https://pypi.org/project/flake8/)
by running `tox -e flake8`.
### Documentation ### Documentation

View File

@ -33,6 +33,8 @@ PasswordResetConfirmSerializer = import_callable(serializers.get(
'PASSWORD_RESET_CONFIRM_SERIALIZER', DefaultPasswordResetConfirmSerializer 'PASSWORD_RESET_CONFIRM_SERIALIZER', DefaultPasswordResetConfirmSerializer
)) ))
PasswordChangeSerializer = import_callable(serializers.get('PASSWORD_CHANGE_SERIALIZER', DefaultPasswordChangeSerializer)) PasswordChangeSerializer = import_callable(
serializers.get('PASSWORD_CHANGE_SERIALIZER', DefaultPasswordChangeSerializer)
)
JWT_AUTH_COOKIE = getattr(settings, 'JWT_AUTH_COOKIE', None) JWT_AUTH_COOKIE = getattr(settings, 'JWT_AUTH_COOKIE', None)

View File

@ -17,7 +17,6 @@ except ImportError:
raise ImportError("allauth needs to be added to INSTALLED_APPS.") raise ImportError("allauth needs to be added to INSTALLED_APPS.")
class SocialAccountSerializer(serializers.ModelSerializer): class SocialAccountSerializer(serializers.ModelSerializer):
""" """
serialize allauth SocialAccounts for use with a REST API serialize allauth SocialAccounts for use with a REST API

View File

@ -21,7 +21,6 @@ from . import django_urls
class ExampleProtectedView(APIView): class ExampleProtectedView(APIView):
permission_classes = [permissions.IsAuthenticated] permission_classes = [permissions.IsAuthenticated]
def get(self, *args, **kwargs): def get(self, *args, **kwargs):
return Response(dict(success=True)) return Response(dict(success=True))

View File

@ -146,7 +146,6 @@ class LogoutView(APIView):
from rest_framework_simplejwt.exceptions import TokenError from rest_framework_simplejwt.exceptions import TokenError
from rest_framework_simplejwt.tokens import RefreshToken from rest_framework_simplejwt.tokens import RefreshToken
cookie_name = getattr(settings, 'JWT_AUTH_COOKIE', None) cookie_name = getattr(settings, 'JWT_AUTH_COOKIE', None)
if cookie_name: if cookie_name:
response.delete_cookie(cookie_name) response.delete_cookie(cookie_name)

37
tox.ini Normal file
View File

@ -0,0 +1,37 @@
# tox (https://tox.readthedocs.io/) 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.
# Running this tox will test against all supported version
# combinations of python and django as described at the following
# https://docs.djangoproject.com/en/3.0/faq/install/#what-python-version-can-i-use-with-django
# https://endoflife.date/django
[tox]
skipsdist = true
envlist =
python{3.5,3.6,3.7,3.8}-django22
python{3.6,3.7,3.8}-django30
[testenv]
commands =
python ./runtests.py
deps =
-rdev-requirements.txt
django22: Django>=2.2,<2.3
django30: Django>=3.0,<3.1
# Configuration for coverage and flake8 is being set in `./setup.cfg`
[testenv:coverage]
commands =
coverage run ./runtests.py
coverage report
deps =
-rdev-requirements.txt
[testenv:flake8]
changedir = {toxinidir}/dj_rest_auth
commands =
flake8 .
deps =
flake8==3.8.1