mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +03:00
Merge 75a4f61835
into a44cb67988
This commit is contained in:
commit
e1a182b631
|
@ -21,6 +21,8 @@ matrix:
|
|||
- { python: "3.6", env: DJANGO=master }
|
||||
- { python: "3.6", env: DJANGO=1.11 }
|
||||
- { python: "3.6", env: DJANGO=2.0 }
|
||||
- { python: "3.6", env: DJANGO=2.0 }
|
||||
- { python: "3.6", env: TOXENV=py36-django20-base }
|
||||
- { python: "3.6", env: DJANGO=2.1 }
|
||||
- { python: "2.7", env: TOXENV=lint }
|
||||
- { python: "2.7", env: TOXENV=docs }
|
||||
|
@ -32,6 +34,13 @@ matrix:
|
|||
- tox --installpkg ./dist/djangorestframework-*.whl
|
||||
- tox # test sdist
|
||||
|
||||
- python: "3.6"
|
||||
env: TOXENV=dist-base
|
||||
script:
|
||||
- python setup.py bdist_wheel
|
||||
- tox --installpkg ./dist/djangorestframework-*.whl
|
||||
- tox # test sdist
|
||||
|
||||
exclude:
|
||||
- { python: "2.7", env: DJANGO=master }
|
||||
- { python: "2.7", env: DJANGO=2.0 }
|
||||
|
|
|
@ -76,6 +76,7 @@ class JSONEncoderTests(TestCase):
|
|||
unique_id = uuid4()
|
||||
assert self.encoder.default(unique_id) == str(unique_id)
|
||||
|
||||
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||
def test_encode_coreapi_raises_error(self):
|
||||
"""
|
||||
Tests encoding a coreapi objects raises proper error
|
||||
|
|
|
@ -10,6 +10,7 @@ from django.test.utils import override_settings
|
|||
from django.utils.six.moves import reload_module
|
||||
|
||||
from rest_framework import filters, generics, serializers
|
||||
from rest_framework.compat import coreschema
|
||||
from rest_framework.test import APIRequestFactory
|
||||
|
||||
factory = APIRequestFactory()
|
||||
|
@ -28,6 +29,7 @@ class BaseFilterTests(TestCase):
|
|||
with pytest.raises(NotImplementedError):
|
||||
self.filter_backend.filter_queryset(None, None, None)
|
||||
|
||||
@pytest.mark.skipif(not coreschema, reason='coreschema is not installed')
|
||||
def test_get_schema_fields_checks_for_coreapi(self):
|
||||
filters.coreapi = None
|
||||
with pytest.raises(AssertionError):
|
||||
|
|
|
@ -709,6 +709,7 @@ class AdminRendererTests(TestCase):
|
|||
self.assertContains(response, '<tr><th>Iteritems</th><td>a string</td></tr>', html=True)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||
class TestDocumentationRenderer(TestCase):
|
||||
|
||||
def test_document_with_link_named_data(self):
|
||||
|
@ -738,6 +739,7 @@ class TestDocumentationRenderer(TestCase):
|
|||
assert '<h1>Data Endpoint API</h1>' in html
|
||||
|
||||
|
||||
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||
class TestSchemaJSRenderer(TestCase):
|
||||
|
||||
def test_schemajs_output(self):
|
||||
|
|
|
@ -663,6 +663,7 @@ class TestAutoSchema(TestCase):
|
|||
with pytest.raises(AssertionError):
|
||||
descriptor.get_link(None, None, None) # ???: Do the dummy arguments require a tighter assert?
|
||||
|
||||
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||
def test_update_fields(self):
|
||||
"""
|
||||
That updating fields by-name helper is correct
|
||||
|
@ -698,6 +699,7 @@ class TestAutoSchema(TestCase):
|
|||
assert len(fields) == 1
|
||||
assert fields[0].required is False
|
||||
|
||||
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||
def test_get_manual_fields(self):
|
||||
"""That get_manual_fields is applied during get_link"""
|
||||
|
||||
|
@ -718,6 +720,7 @@ class TestAutoSchema(TestCase):
|
|||
assert len(fields) == 2
|
||||
assert "my_extra_field" in [f.name for f in fields]
|
||||
|
||||
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||
def test_view_with_manual_schema(self):
|
||||
|
||||
path = '/example'
|
||||
|
@ -764,6 +767,7 @@ class TestAutoSchema(TestCase):
|
|||
link = view.schema.get_link(path, method, base_url)
|
||||
assert link == expected
|
||||
|
||||
@unittest.skipUnless(coreschema, 'coreschema is not installed')
|
||||
def test_field_to_schema(self):
|
||||
label = 'Test label'
|
||||
help_text = 'This is a helpful test text'
|
||||
|
@ -983,6 +987,7 @@ naming_collisions_router = SimpleRouter()
|
|||
naming_collisions_router.register(r'collision', NamingCollisionViewSet, base_name="collision")
|
||||
|
||||
|
||||
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||
class TestURLNamingCollisions(TestCase):
|
||||
"""
|
||||
Ref: https://github.com/encode/django-rest-framework/issues/4704
|
||||
|
@ -1167,6 +1172,7 @@ def test_head_and_options_methods_are_excluded():
|
|||
assert inspector.get_allowed_methods(callback) == ["GET"]
|
||||
|
||||
|
||||
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||
class TestAutoSchemaAllowsFilters(object):
|
||||
class MockAPIView(APIView):
|
||||
filter_backends = [filters.OrderingFilter]
|
||||
|
|
|
@ -5,8 +5,12 @@ We need only the docs urls for DocumentationRenderer tests.
|
|||
"""
|
||||
from django.conf.urls import url
|
||||
|
||||
from rest_framework.compat import coreapi
|
||||
from rest_framework.documentation import include_docs_urls
|
||||
|
||||
urlpatterns = [
|
||||
if coreapi:
|
||||
urlpatterns = [
|
||||
url(r'^docs/', include_docs_urls(title='Test Suite API')),
|
||||
]
|
||||
]
|
||||
else:
|
||||
urlpatterns = []
|
||||
|
|
9
tox.ini
9
tox.ini
|
@ -21,20 +21,25 @@ envdir = {toxworkdir}/venvs/{envname}
|
|||
setenv =
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
PYTHONWARNINGS=once
|
||||
base: _DRF_TESTS_OPTIONAL_DEPS=
|
||||
deps =
|
||||
django110: Django>=1.10,<1.11
|
||||
django111: Django>=1.11,<2.0
|
||||
django20: Django>=2.0,<2.1
|
||||
django21: Django>=2.1b1,<2.2
|
||||
djangomaster: https://github.com/django/django/archive/master.tar.gz
|
||||
{env:_DRF_TESTS_OPTIONAL_DEPS:-rrequirements/requirements-optionals.txt}
|
||||
-rrequirements/requirements-testing.txt
|
||||
-rrequirements/requirements-optionals.txt
|
||||
|
||||
[testenv:dist]
|
||||
[testenv:dist-base]
|
||||
commands = ./runtests.py --fast {posargs} --no-pkgroot --staticfiles -rw
|
||||
deps =
|
||||
django
|
||||
-rrequirements/requirements-testing.txt
|
||||
|
||||
[testenv:dist]
|
||||
commands = {[testenv:dist-base]commands}
|
||||
deps = {[testenv:dist-base]deps}
|
||||
-rrequirements/requirements-optionals.txt
|
||||
|
||||
[testenv:lint]
|
||||
|
|
Loading…
Reference in New Issue
Block a user