mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 01:26:53 +03:00
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:
parent
fe840a34ff
commit
7fbbfe2c60
|
@ -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 }
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -67,19 +67,22 @@ def pytest_configure(config):
|
||||||
)
|
)
|
||||||
|
|
||||||
# guardian is optional
|
# guardian is optional
|
||||||
try:
|
# Note that for the test cases we're installing a version of django-guardian
|
||||||
import guardian # NOQA
|
# that's only compatible with Django 2.0+.
|
||||||
except ImportError:
|
if django.VERSION >= (2, 0, 0):
|
||||||
pass
|
try:
|
||||||
else:
|
import guardian # NOQA
|
||||||
settings.ANONYMOUS_USER_ID = -1
|
except ImportError:
|
||||||
settings.AUTHENTICATION_BACKENDS = (
|
pass
|
||||||
'django.contrib.auth.backends.ModelBackend',
|
else:
|
||||||
'guardian.backends.ObjectPermissionBackend',
|
settings.ANONYMOUS_USER_ID = -1
|
||||||
)
|
settings.AUTHENTICATION_BACKENDS = (
|
||||||
settings.INSTALLED_APPS += (
|
'django.contrib.auth.backends.ModelBackend',
|
||||||
'guardian',
|
'guardian.backends.ObjectPermissionBackend',
|
||||||
)
|
)
|
||||||
|
settings.INSTALLED_APPS += (
|
||||||
|
'guardian',
|
||||||
|
)
|
||||||
|
|
||||||
if config.getoption('--no-pkgroot'):
|
if config.getoption('--no-pkgroot'):
|
||||||
sys.path.pop(0)
|
sys.path.pop(0)
|
||||||
|
|
|
@ -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([
|
||||||
|
|
3
tox.ini
3
tox.ini
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user