Django 3 compat (#7058)

* First pass at Django 3.0 compat

* Drop Guardian for 1.11 tests, since we're installing an incompatible version

* Fix ROOT_URLCONF override in test case

* Fix typo

Co-Authored-By: Rémy HUBSCHER <hubscher.remy@gmail.com>

* Linting
This commit is contained in:
Tom Christie 2019-11-21 11:55:53 +00:00 committed by GitHub
parent fe840a34ff
commit 7fbbfe2c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 16 deletions

View File

@ -14,13 +14,16 @@ matrix:
- { python: "3.6", env: DJANGO=2.0 } - { python: "3.6", env: DJANGO=2.0 }
- { python: "3.6", env: DJANGO=2.1 } - { python: "3.6", env: DJANGO=2.1 }
- { python: "3.6", env: DJANGO=2.2 } - { python: "3.6", env: DJANGO=2.2 }
- { python: "3.6", env: DJANGO=3.0 }
- { python: "3.6", env: DJANGO=master } - { python: "3.6", env: DJANGO=master }
- { python: "3.7", env: DJANGO=2.0 } - { python: "3.7", env: DJANGO=2.0 }
- { python: "3.7", env: DJANGO=2.1 } - { python: "3.7", env: DJANGO=2.1 }
- { python: "3.7", env: DJANGO=2.2 } - { python: "3.7", env: DJANGO=2.2 }
- { python: "3.7", env: DJANGO=3.0 }
- { python: "3.7", env: DJANGO=master } - { python: "3.7", env: DJANGO=master }
- { python: "3.8", env: DJANGO=3.0 }
- { python: "3.8", env: DJANGO=master } - { python: "3.8", env: DJANGO=master }
- { python: "3.8", env: TOXENV=base } - { python: "3.8", env: TOXENV=base }

View File

@ -2,7 +2,7 @@
psycopg2-binary>=2.8.2, <2.9 psycopg2-binary>=2.8.2, <2.9
markdown==3.1.1 markdown==3.1.1
pygments==2.4.2 pygments==2.4.2
django-guardian==1.5.0 django-guardian==2.1.0
django-filter>=2.2.0, <2.3 django-filter>=2.2.0, <2.3
coreapi==2.3.1 coreapi==2.3.1
coreschema==0.0.4 coreschema==0.0.4

View File

@ -67,6 +67,9 @@ def pytest_configure(config):
) )
# guardian is optional # guardian is optional
# Note that for the test cases we're installing a version of django-guardian
# that's only compatible with Django 2.0+.
if django.VERSION >= (2, 0, 0):
try: try:
import guardian # NOQA import guardian # NOQA
except ImportError: except ImportError:

View File

@ -145,9 +145,12 @@ class TestProxiedPrimaryKeyRelatedField(APISimpleTestCase):
assert representation == self.instance.pk.int assert representation == self.instance.pk.int
@override_settings(ROOT_URLCONF=[ urlpatterns = [
url(r'^example/(?P<name>.+)/$', lambda: None, name='example'), url(r'^example/(?P<name>.+)/$', lambda: None, name='example'),
]) ]
@override_settings(ROOT_URLCONF='tests.test_relations')
class TestHyperlinkedRelatedField(APISimpleTestCase): class TestHyperlinkedRelatedField(APISimpleTestCase):
def setUp(self): def setUp(self):
self.queryset = MockQueryset([ self.queryset = MockQueryset([

View File

@ -4,6 +4,7 @@ envlist =
{py35,py36,py37}-django20, {py35,py36,py37}-django20,
{py35,py36,py37}-django21 {py35,py36,py37}-django21
{py35,py36,py37}-django22 {py35,py36,py37}-django22
{py36,py37,py38}-django30,
{py36,py37,py38}-djangomaster, {py36,py37,py38}-djangomaster,
base,dist,lint,docs, base,dist,lint,docs,
@ -13,6 +14,7 @@ DJANGO =
2.0: django20 2.0: django20
2.1: django21 2.1: django21
2.2: django22 2.2: django22
3.0: django30
master: djangomaster master: djangomaster
[testenv] [testenv]
@ -26,6 +28,7 @@ deps =
django20: Django>=2.0,<2.1 django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2 django21: Django>=2.1,<2.2
django22: Django>=2.2,<3.0 django22: Django>=2.2,<3.0
django30: Django==3.0rc1
djangomaster: https://github.com/django/django/archive/master.tar.gz djangomaster: https://github.com/django/django/archive/master.tar.gz
-rrequirements/requirements-testing.txt -rrequirements/requirements-testing.txt
-rrequirements/requirements-optionals.txt -rrequirements/requirements-optionals.txt