Improve testing (#415)

These changes:

 - Fix the lint and the djmaster jobs
 - Fix compatibility with upcoming Django 3.0
 - Replace jobs with matrix in .travis.yml
 - Add a test job for Python 3.8
 - Allow running tests on any branch
master
Aliaksei Urbanski 2019-10-03 01:38:02 +03:00 committed by Cristi Vîjdea
parent 16f67cd8c2
commit 9a89d8ccb0
8 changed files with 28 additions and 23 deletions

View File

@ -4,12 +4,13 @@ python:
- '3.5' - '3.5'
- '3.6' - '3.6'
- '3.7' - '3.7'
- '3.8-dev'
dist: xenial dist: xenial
cache: pip cache: pip
jobs: matrix:
include: include:
- python: '3.6' - python: '3.6'
env: TOXENV=docs env: TOXENV=docs
@ -38,6 +39,7 @@ jobs:
allow_failures: allow_failures:
- env: TOXENV=lint - env: TOXENV=lint
- env: TOXENV=djmaster - env: TOXENV=djmaster
- python: '3.8-dev'
fast_finish: true fast_finish: true
@ -59,11 +61,6 @@ after_success:
codecov codecov
fi fi
branches:
only:
- master
- /^v?\d+\.\d+(\.\d+)?(-?\S+)?$/
stages: stages:
- test - test
- name: publish - name: publish

View File

@ -1,6 +1,5 @@
# test project requirements # test project requirements
Pillow>=4.3.0 Pillow>=4.3.0
django-cors-headers>=2.1.0
django-filter>=1.1.0,<2.0; python_version == "2.7" django-filter>=1.1.0,<2.0; python_version == "2.7"
django-filter>=1.1.0; python_version >= "3.5" django-filter>=1.1.0; python_version >= "3.5"
#djangorestframework-camel-case>=0.2.0 #djangorestframework-camel-case>=0.2.0
@ -9,5 +8,3 @@ django-filter>=1.1.0; python_version >= "3.5"
djangorestframework-recursive>=0.1.2 djangorestframework-recursive>=0.1.2
dj-database-url>=0.4.2 dj-database-url>=0.4.2
user_agents>=1.1.0 user_agents>=1.1.0
# django-oauth-toolkit 1.2 does not support Django 1.11
django-oauth-toolkit>=1.1.0,<1.2.0

View File

@ -5,7 +5,7 @@ from .base import (
from .field import ( from .field import (
CamelCaseJSONFilter, ChoiceFieldInspector, DictFieldInspector, FileFieldInspector, HiddenFieldInspector, CamelCaseJSONFilter, ChoiceFieldInspector, DictFieldInspector, FileFieldInspector, HiddenFieldInspector,
InlineSerializerInspector, JSONFieldInspector, RecursiveFieldInspector, ReferencingSerializerInspector, InlineSerializerInspector, JSONFieldInspector, RecursiveFieldInspector, ReferencingSerializerInspector,
RelatedFieldInspector, SerializerMethodFieldInspector, SimpleFieldInspector, StringDefaultFieldInspector RelatedFieldInspector, SerializerMethodFieldInspector, SimpleFieldInspector, StringDefaultFieldInspector
) )
from .query import CoreAPICompatInspector, DjangoRestResponsePagination from .query import CoreAPICompatInspector, DjangoRestResponsePagination
from .view import SwaggerAutoSchema from .view import SwaggerAutoSchema

View File

@ -2,7 +2,7 @@ import six
from django.shortcuts import resolve_url from django.shortcuts import resolve_url
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.utils.encoding import force_text from django.utils.encoding import force_str
from django.utils.functional import Promise from django.utils.functional import Promise
from rest_framework.renderers import BaseRenderer, JSONRenderer, TemplateHTMLRenderer from rest_framework.renderers import BaseRenderer, JSONRenderer, TemplateHTMLRenderer
from rest_framework.utils import encoders, json from rest_framework.utils import encoders, json
@ -124,7 +124,7 @@ class SwaggerUIRenderer(_UIRenderer):
swagger_ui_settings = self.get_swagger_ui_settings() swagger_ui_settings = self.get_swagger_ui_settings()
request = renderer_context.get('request', None) request = renderer_context.get('request', None)
oauth_redirect_url = force_text(swagger_ui_settings.get('oauth2RedirectUrl', '')) oauth_redirect_url = force_str(swagger_ui_settings.get('oauth2RedirectUrl', ''))
if request and oauth_redirect_url: if request and oauth_redirect_url:
swagger_ui_settings['oauth2RedirectUrl'] = request.build_absolute_uri(oauth_redirect_url) swagger_ui_settings['oauth2RedirectUrl'] = request.build_absolute_uri(oauth_redirect_url)

View File

@ -5,7 +5,7 @@ from collections import OrderedDict
from decimal import Decimal from decimal import Decimal
from django.db import models from django.db import models
from django.utils.encoding import force_text from django.utils.encoding import force_str
from rest_framework import serializers, status from rest_framework import serializers, status
from rest_framework.mixins import DestroyModelMixin, ListModelMixin, RetrieveModelMixin, UpdateModelMixin from rest_framework.mixins import DestroyModelMixin, ListModelMixin, RetrieveModelMixin, UpdateModelMixin
from rest_framework.parsers import FileUploadParser from rest_framework.parsers import FileUploadParser
@ -434,7 +434,7 @@ def force_real_str(s, encoding='utf-8', strings_only=False, errors='strict'):
Fix for https://github.com/axnsan12/drf-yasg/issues/159 Fix for https://github.com/axnsan12/drf-yasg/issues/159
""" """
if s is not None: if s is not None:
s = force_text(s, encoding, strings_only, errors) s = force_str(s, encoding, strings_only, errors)
if type(s) != str: if type(s) != str:
s = '' + s s = '' + s

View File

@ -1,8 +1,7 @@
import warnings import warnings
from functools import wraps from functools import WRAPPER_ASSIGNMENTS, wraps
from django.utils.cache import add_never_cache_headers from django.utils.cache import add_never_cache_headers
from django.utils.decorators import available_attrs
from django.views.decorators.cache import cache_page from django.views.decorators.cache import cache_page
from django.views.decorators.vary import vary_on_headers from django.views.decorators.vary import vary_on_headers
from rest_framework import exceptions from rest_framework import exceptions
@ -30,7 +29,7 @@ def deferred_never_cache(view_func):
never be cached. never be cached.
""" """
@wraps(view_func, assigned=available_attrs(view_func)) @wraps(view_func, assigned=WRAPPER_ASSIGNMENTS)
def _wrapped_view_func(request, *args, **kwargs): def _wrapped_view_func(request, *args, **kwargs):
response = view_func(request, *args, **kwargs) response = view_func(request, *args, **kwargs)

View File

@ -13,7 +13,6 @@ else:
from django.core.validators import MaxLengthValidator, MinValueValidator from django.core.validators import MaxLengthValidator, MinValueValidator
class LanguageSerializer(serializers.Serializer): class LanguageSerializer(serializers.Serializer):
name = serializers.ChoiceField( name = serializers.ChoiceField(
choices=LANGUAGE_CHOICES, default='python', help_text='The name of the programming language') choices=LANGUAGE_CHOICES, default='python', help_text='The name of the programming language')

23
tox.ini
View File

@ -8,9 +8,10 @@ envlist =
py27-django111-drf39-typing, py27-django111-drf39-typing,
py27-django111-drf{38,39}, py27-django111-drf{38,39},
py{35,36}-django{111,21,22}-drf{38,39}, py{35,36}-django{111,21,22}-drf{38,39},
py37-django{21,22}-drf{38,39}, py37-django{21,22}-drf{38,39,310},
py37-django{21,22}-drf310, py38-django22-drf310,
djmaster, lint, docs djmaster, lint, docs
skip_missing_interpreters = true
[testenv:.package] [testenv:.package]
# no additional dependencies besides PEP 517 # no additional dependencies besides PEP 517
@ -19,8 +20,17 @@ deps =
[testenv] [testenv]
deps = deps =
django111: Django>=1.11,<2.0 django111: Django>=1.11,<2.0
django111: django-cors-headers>=2.1.0
django111: django-oauth-toolkit>=1.1.0,<1.2.0
django21: Django>=2.1,<2.2 django21: Django>=2.1,<2.2
django21: django-cors-headers>=2.1.0
django21: django-oauth-toolkit>=1.2.0
django22: Django>=2.2,<2.3 django22: Django>=2.2,<2.3
django22: django-cors-headers>=2.1.0
django22: django-oauth-toolkit>=1.2.0
drf38: djangorestframework>=3.8,<3.9 drf38: djangorestframework>=3.8,<3.9
drf39: djangorestframework>=3.9,<3.10 drf39: djangorestframework>=3.9,<3.10
@ -28,9 +38,12 @@ deps =
typing: typing>=3.6.6 typing: typing>=3.6.6
# test with the latest build of django-rest-framework to get early warning of compatibility issues # test with the latest builds of Django and django-rest-framework
djmaster: https://github.com/encode/django-rest-framework/archive/master.tar.gz # to get early warning of compatibility issues
djmaster: https://github.com/django/django/archive/master.tar.gz djmaster: https://github.com/django/django/archive/master.tar.gz
djmaster: https://github.com/ottoyiu/django-cors-headers/archive/master.tar.gz
djmaster: https://github.com/encode/django-rest-framework/archive/master.tar.gz
djmaster: django-oauth-toolkit>=1.2.0
# other dependencies # other dependencies
-r requirements/validation.txt -r requirements/validation.txt
@ -77,5 +90,5 @@ known_standard_library =
known_third_party = known_third_party =
coreapi,coreschema,datadiff,dj_database_url,django,django_filters,djangorestframework_camel_case, coreapi,coreschema,datadiff,dj_database_url,django,django_filters,djangorestframework_camel_case,
rest_framework_recursive,flex,gunicorn,inflection,pytest,rest_framework,ruamel,setuptools_scm, rest_framework_recursive,flex,gunicorn,inflection,pytest,rest_framework,ruamel,setuptools_scm,
swagger_spec_validator,uritemplate,user_agents,whitenoise,oauth2_provider swagger_spec_validator,uritemplate,user_agents,whitenoise,oauth2_provider,packaging
known_first_party = drf_yasg,testproj,articles,people,snippets,todo,users,urlconfs known_first_party = drf_yasg,testproj,articles,people,snippets,todo,users,urlconfs