From a3107dac9238a6bd9fde635a96a46517846e1a52 Mon Sep 17 00:00:00 2001 From: Ichiro Hiraide Date: Wed, 11 Sep 2019 17:28:23 +0900 Subject: [PATCH 1/3] DRF 3.10 drops python2 support --- tox.ini | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 1d38dafd..6684c539 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,10 @@ [tox] envlist = py27-{flake8,docs}, - {py27,py34,py35,py36}-django{1.11}-drf{3.6,3.7,3.8} + {py27,py34}-django1.11-drf{3.6,3.7,3.8,3.9} + {py34,py35,py36,py37}-django1.11-drf{3.6,3.7,3.8,3.9,3.10} {py34}-django{2.0}-drf{3.7,3.8} - {py35,py36,py37}-django{2.0,2.1,2.2}-drf{3.7,3.8,3.9} + {py35,py36,py37}-django{2.0,2.1,2.2}-drf{3.7,3.8,3.9,3.10} [testenv] @@ -19,6 +20,7 @@ deps = drf3.7: djangorestframework>=3.7,<3.8 drf3.8: djangorestframework>=3.8,<3.9 drf3.9: djangorestframework>=3.9,<3.10 + drf3.10: djangorestframework>=3.10,<3.11 pytest-django==3.4.2 -rrequirements-tox.txt From 6fec0825430a4a9b3c71dcb179be619a47ceeaa2 Mon Sep 17 00:00:00 2001 From: Ichiro Hiraide Date: Wed, 11 Sep 2019 17:35:25 +0900 Subject: [PATCH 2/3] fix tests/test_dynamic_routers.py (deprecation of list_route/detail_route) --- tests/test_dynamic_routers.py | 22 ++++++++++++++++++---- tox.ini | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/test_dynamic_routers.py b/tests/test_dynamic_routers.py index ac44a6ce..531c860a 100644 --- a/tests/test_dynamic_routers.py +++ b/tests/test_dynamic_routers.py @@ -22,11 +22,25 @@ class Meta: app_label = 'testapp' +# DRF 3.8+ try: - from rest_framework.decorators import detail_route, list_route + from rest_framework.decorators import action + + def detail_route_decorator(**kwargs): + return action(detail=True, **kwargs) + + def list_route_decorator(**kwargs): + return action(detail=False, **kwargs) except ImportError: pass -else: + +# for DRF < 3.8 +try: + from rest_framework.decorators import detail_route as detail_route_decorator, list_route as list_route_decorator +except ImportError: + pass + +if 'detail_route_decorator' in globals() and 'list_route_decorator' in globals(): def map_by_name(iterable): ret = {} for item in iterable: @@ -37,7 +51,7 @@ class DetailRouteViewSet(ModelViewSet): model = BasicModel queryset = QS(BasicModel) - @detail_route(methods=["post"]) + @detail_route_decorator(methods=["post"]) def set_password(self, request, pk=None): return Response({'hello': 'ok'}) @@ -45,7 +59,7 @@ class ListRouteViewSet(ModelViewSet): model = BasicModel queryset = QS(BasicModel) - @list_route() + @list_route_decorator() def recent_users(self, request, pk=None): return Response([{'hello': 'ok'}]) diff --git a/tox.ini b/tox.ini index 6684c539..85f84ae3 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ envlist = py27-{flake8,docs}, {py27,py34}-django1.11-drf{3.6,3.7,3.8,3.9} - {py34,py35,py36,py37}-django1.11-drf{3.6,3.7,3.8,3.9,3.10} + {py35,py36,py37}-django1.11-drf{3.6,3.7,3.8,3.9,3.10} {py34}-django{2.0}-drf{3.7,3.8} {py35,py36,py37}-django{2.0,2.1,2.2}-drf{3.7,3.8,3.9,3.10} From 660cbabde9c0f69cf3ae7b09c95aa0fa0fdd045e Mon Sep 17 00:00:00 2001 From: Ichiro Hiraide Date: Wed, 11 Sep 2019 17:44:59 +0900 Subject: [PATCH 3/3] fix of lint --- tests/test_dynamic_routers.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_dynamic_routers.py b/tests/test_dynamic_routers.py index 531c860a..a428e603 100644 --- a/tests/test_dynamic_routers.py +++ b/tests/test_dynamic_routers.py @@ -32,13 +32,12 @@ def detail_route_decorator(**kwargs): def list_route_decorator(**kwargs): return action(detail=False, **kwargs) except ImportError: - pass + # for DRF < 3.8 + try: + from rest_framework.decorators import detail_route as detail_route_decorator, list_route as list_route_decorator + except ImportError: + pass -# for DRF < 3.8 -try: - from rest_framework.decorators import detail_route as detail_route_decorator, list_route as list_route_decorator -except ImportError: - pass if 'detail_route_decorator' in globals() and 'list_route_decorator' in globals(): def map_by_name(iterable):