From 9a322c472920a71cb9d54d3d59e14a5ced75875c Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Mon, 23 Nov 2020 18:54:00 +0100 Subject: [PATCH] Add support for Python 3.9 --- .travis.yml | 1 + README.rst | 2 +- defender/test.py | 2 +- defender/test_settings.py | 5 +++++ defender/travis_settings.py | 4 ++++ setup.py | 3 ++- tox.ini | 3 ++- 7 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c0fcbbd..f6025f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ python: - '3.6' - '3.7' - '3.8' +- '3.9' - pypy3 services: - redis-server diff --git a/README.rst b/README.rst index 01b956f..4187c65 100644 --- a/README.rst +++ b/README.rst @@ -108,7 +108,7 @@ Admin pages Requirements ------------ -* Python: 3.6, 3.7, 3.8, PyPy +* Python: 3.6, 3.7, 3.8, 3.9, PyPy * Django: 2.2, 3.x * Redis diff --git a/defender/test.py b/defender/test.py index ffcd277..9156509 100644 --- a/defender/test.py +++ b/defender/test.py @@ -3,7 +3,7 @@ from django.test.testcases import TestCase, TransactionTestCase from .connection import get_redis_connection -class DefenderTestCaseMixin(object): +class DefenderTestCaseMixin: """Mixin used to provide a common tearDown method""" def tearDown(self): diff --git a/defender/test_settings.py b/defender/test_settings.py index 3371b10..0763c65 100644 --- a/defender/test_settings.py +++ b/defender/test_settings.py @@ -1,6 +1,9 @@ import os + +import django from celery import Celery + DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:",}} @@ -42,6 +45,8 @@ TEMPLATES = [ }, }, ] +if django.VERSION > (3, 1): + TEMPLATES[0]["OPTIONS"]["context_processors"].append("django.template.context_processors.request") SECRET_KEY = os.environ.get("SECRET_KEY", "too-secret-for-test") diff --git a/defender/travis_settings.py b/defender/travis_settings.py index 868c963..a4942c4 100644 --- a/defender/travis_settings.py +++ b/defender/travis_settings.py @@ -1,4 +1,6 @@ import os + +import django from celery import Celery @@ -47,6 +49,8 @@ TEMPLATES = [ }, }, ] +if django.VERSION > (3, 1): + TEMPLATES[0]["OPTIONS"]["context_processors"].append("django.template.context_processors.request") SECRET_KEY = os.environ.get("SECRET_KEY", "too-secret-for-test") diff --git a/setup.py b/setup.py index f3d55b7..512dc21 100644 --- a/setup.py +++ b/setup.py @@ -44,6 +44,7 @@ setup( "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", @@ -60,7 +61,7 @@ setup( packages=find_packages(), package_data=get_package_data("defender"), python_requires='~=3.5', - install_requires=["Django>=1.8,<3.2", "redis<3.6"], + install_requires=["Django>=2.2,<3.2", "redis<3.6"], tests_require=[ "mockredispy>=2.9.0.11,<3.0", "coverage", diff --git a/tox.ini b/tox.ini index 1cc6fdf..919835b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = # list of supported Django/Python versioons: - py{36,37,38,py3}-django{22,30,31,master} + py{36,37,38,39,py3}-django{22,30,31,master} py38-{lint,docs} [travis] @@ -9,6 +9,7 @@ python = 3.6: py36 3.7: py37 3.8: py38 + 3.9: py39 pypy3: pypy3 [testenv]