Skip to content

Commit e44b685

Browse files
committed
Clean up testing setup
1 parent 7c1d303 commit e44b685

15 files changed

+157
-201
lines changed

Makefile

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
CURRENT_SIGN_SETTING := $(shell git config commit.gpgSign)
2+
3+
.PHONY: clean-pyc clean-build docs
4+
5+
help:
6+
@echo "clean-build - remove build artifacts"
7+
@echo "clean-pyc - remove Python file artifacts"
8+
@echo "lint - check style with flake8"
9+
@echo "test - run tests quickly with the default Python"
10+
@echo "testall - run tests on every Python version with tox"
11+
@echo "release - package and upload a release"
12+
@echo "dist - package"
13+
14+
clean: clean-build clean-pyc
15+
16+
clean-build:
17+
rm -fr build/
18+
rm -fr dist/
19+
rm -fr *.egg-info
20+
21+
clean-pyc:
22+
find . -name '*.pyc' -exec rm -f {} +
23+
find . -name '*.pyo' -exec rm -f {} +
24+
find . -name '*~' -exec rm -f {} +
25+
26+
lint:
27+
tox -e lint
28+
29+
lint-roll:
30+
isort --recursive rest_framework_simplejwt tests
31+
$(MAKE) lint
32+
33+
test:
34+
pytest tests
35+
36+
test-all:
37+
tox
38+
39+
build-docs:
40+
sphinx-apidoc -o docs/ . setup.py "*conftest*"
41+
$(MAKE) -C docs clean
42+
$(MAKE) -C docs html
43+
$(MAKE) -C docs doctest
44+
45+
docs: build-docs
46+
open docs/_build/html/index.html
47+
48+
linux-docs: build-docs
49+
xdg-open docs/_build/html/index.html
50+
51+
release: clean
52+
git config commit.gpgSign true
53+
bumpversion $(bump)
54+
git push upstream && git push upstream --tags
55+
python setup.py sdist bdist_wheel
56+
twine upload dist/*
57+
git config commit.gpgSign "$(CURRENT_SIGN_SETTING)"
58+
59+
dist: clean
60+
python setup.py sdist bdist_wheel
61+
ls -l dist

pytest.ini

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[pytest]
2+
addopts= -v --showlocals --durations 10
3+
python_paths= .
4+
xfail_strict=true
5+
6+
[pytest-watch]
7+
runner= pytest --failed-first --maxfail=1 --no-success-flaky-report

requirements.txt

-4
This file was deleted.

requirements/codestyle.txt

-3
This file was deleted.

requirements/optionals.txt

-1
This file was deleted.

requirements/packaging.txt

-2
This file was deleted.

requirements/testing.txt

-5
This file was deleted.

runtests.py

-122
This file was deleted.

setup.py

+48-27
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,65 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
from io import open
4-
import os
5-
import re
6-
import shutil
7-
import sys
8-
9-
from setuptools import setup, find_packages
10-
11-
12-
init_py = open(os.path.join('rest_framework_simplejwt', '__init__.py')).read()
13-
version = re.search(r'''^__version__ = ['"]([^'"]+)['"]$''', init_py).group(1)
3+
from setuptools import (
4+
setup,
5+
find_packages,
6+
)
147

8+
extras_require = {
9+
'test': [
10+
'cryptography',
11+
'pytest-cov',
12+
'pytest-django',
13+
'pytest-xdist',
14+
'pytest',
15+
'tox',
16+
],
17+
'lint': [
18+
'flake8',
19+
'pep8',
20+
'isort',
21+
],
22+
'doc': [
23+
'Sphinx>=1.6.5,<2',
24+
'sphinx_rtd_theme>=0.1.9',
25+
],
26+
'dev': [
27+
'bumpversion>=0.5.3,<1',
28+
'pytest-watch',
29+
'wheel',
30+
'twine',
31+
'ipython',
32+
],
33+
'python-jose': [
34+
'python-jose==1.3.2',
35+
],
36+
}
1537

16-
if sys.argv[-1] == 'publish':
17-
if os.system('pip freeze | grep twine'):
18-
print('twine not installed.\nUse `pip install twine`.\nExiting.')
19-
sys.exit()
20-
os.system('python setup.py sdist bdist_wheel')
21-
os.system('twine upload dist/*')
22-
print('You probably want to also tag the version now:')
23-
print(" git tag -a %s -m 'version %s'" % (version, version))
24-
print(' git push --tags')
25-
shutil.rmtree('dist')
26-
shutil.rmtree('build')
27-
shutil.rmtree('djangorestframework_simplejwt.egg-info')
28-
sys.exit()
38+
extras_require['dev'] = (
39+
extras_require['dev'] + # noqa: W504
40+
extras_require['test'] + # noqa: W504
41+
extras_require['lint'] + # noqa: W504
42+
extras_require['doc'] + # noqa: W504
43+
extras_require['python-jose']
44+
)
2945

3046

3147
setup(
3248
name='djangorestframework_simplejwt',
33-
version=version,
49+
version='3.3.0',
3450
url='https://github.com/davesque/django-rest-framework-simplejwt',
3551
license='MIT',
3652
description='A minimal JSON Web Token authentication plugin for Django REST Framework',
3753
long_description=open('README.rst', 'r', encoding='utf-8').read(),
3854
author='David Sanders',
3955
author_email='[email protected]',
40-
packages=find_packages(exclude=['tests', 'licenses', 'requirements']),
41-
install_requires=['django', 'djangorestframework', 'pyjwt'],
56+
install_requires=[
57+
'django',
58+
'djangorestframework',
59+
'pyjwt',
60+
],
61+
extras_require=extras_require,
62+
packages=find_packages(exclude=['tests', 'tests.*', 'licenses', 'requirements']),
4263
classifiers=[
4364
'Development Status :: 5 - Production/Stable',
4465
'Environment :: Web Environment',

tests/test_serializers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import timedelta
2+
from unittest.mock import patch
23

34
from django.test import TestCase
4-
from mock import patch
55
from rest_framework_simplejwt.exceptions import TokenError
66
from rest_framework_simplejwt.serializers import (
77
TokenObtainPairSerializer, TokenObtainSerializer,

tests/test_token_blacklist.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
from unittest.mock import patch
2+
13
from django.contrib.auth.models import User
24
from django.core.management import call_command
35
from django.test import TestCase
4-
from mock import patch
56
from rest_framework_simplejwt.exceptions import TokenError
67
from rest_framework_simplejwt.settings import api_settings
78
from rest_framework_simplejwt.token_blacklist.models import (

tests/test_tokens.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from datetime import datetime, timedelta
2+
from unittest.mock import patch
23

34
from django.test import TestCase
45
from jose import jwt
5-
from mock import patch
66
from rest_framework_simplejwt.exceptions import TokenError
77
from rest_framework_simplejwt.settings import api_settings
88
from rest_framework_simplejwt.state import User

tests/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from datetime import datetime, timedelta
2+
from unittest.mock import patch
23

34
from django.test import TestCase
45
from django.utils import timezone
5-
from mock import patch
66
from rest_framework_simplejwt.utils import (
77
aware_utcnow, datetime_from_epoch, datetime_to_epoch, format_lazy,
88
make_utc

tests/test_views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from datetime import timedelta
2+
from unittest.mock import patch
23

3-
from mock import patch
44
from rest_framework_simplejwt.settings import api_settings
55
from rest_framework_simplejwt.state import User
66
from rest_framework_simplejwt.tokens import (

0 commit comments

Comments
 (0)