Skip to content

Commit 518ab64

Browse files
committed
tests: fix skipping of tests without coreapi/coreschema
1 parent 7b108ce commit 518ab64

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

tests/test_encoders.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def test_encode_uuid(self):
7676
unique_id = uuid4()
7777
assert self.encoder.default(unique_id) == str(unique_id)
7878

79+
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
7980
def test_encode_coreapi_raises_error(self):
8081
"""
8182
Tests encoding a coreapi objects raises proper error

tests/test_filters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from django.utils.six.moves import reload_module
1111

1212
from rest_framework import filters, generics, serializers
13+
from rest_framework.compat import coreschema
1314
from rest_framework.test import APIRequestFactory
1415

1516
factory = APIRequestFactory()
@@ -28,6 +29,7 @@ def test_filter_queryset_raises_error(self):
2829
with pytest.raises(NotImplementedError):
2930
self.filter_backend.filter_queryset(None, None, None)
3031

32+
@pytest.mark.skipif(not coreschema, reason='coreschema is not installed')
3133
def test_get_schema_fields_checks_for_coreapi(self):
3234
filters.coreapi = None
3335
with pytest.raises(AssertionError):

tests/test_renderers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ def get(self, request):
709709
self.assertContains(response, '<tr><th>Iteritems</th><td>a string</td></tr>', html=True)
710710

711711

712+
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
712713
class TestDocumentationRenderer(TestCase):
713714

714715
def test_document_with_link_named_data(self):
@@ -738,6 +739,7 @@ def test_document_with_link_named_data(self):
738739
assert '<h1>Data Endpoint API</h1>' in html
739740

740741

742+
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
741743
class TestSchemaJSRenderer(TestCase):
742744

743745
def test_schemajs_output(self):

tests/test_schemas.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ def test_get_link_requires_instance(self):
663663
with pytest.raises(AssertionError):
664664
descriptor.get_link(None, None, None) # ???: Do the dummy arguments require a tighter assert?
665665

666+
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
666667
def test_update_fields(self):
667668
"""
668669
That updating fields by-name helper is correct
@@ -698,6 +699,7 @@ def test_update_fields(self):
698699
assert len(fields) == 1
699700
assert fields[0].required is False
700701

702+
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
701703
def test_get_manual_fields(self):
702704
"""That get_manual_fields is applied during get_link"""
703705

@@ -718,6 +720,7 @@ class CustomView(APIView):
718720
assert len(fields) == 2
719721
assert "my_extra_field" in [f.name for f in fields]
720722

723+
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
721724
def test_view_with_manual_schema(self):
722725

723726
path = '/example'
@@ -764,6 +767,7 @@ class CustomView(APIView):
764767
link = view.schema.get_link(path, method, base_url)
765768
assert link == expected
766769

770+
@unittest.skipUnless(coreschema, 'coreschema is not installed')
767771
def test_field_to_schema(self):
768772
label = 'Test label'
769773
help_text = 'This is a helpful test text'
@@ -983,6 +987,7 @@ def detail_export(self, request):
983987
naming_collisions_router.register(r'collision', NamingCollisionViewSet, base_name="collision")
984988

985989

990+
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
986991
class TestURLNamingCollisions(TestCase):
987992
"""
988993
Ref: https://github.com/encode/django-rest-framework/issues/4704
@@ -1167,6 +1172,7 @@ def custom_action(self, request, pk):
11671172
assert inspector.get_allowed_methods(callback) == ["GET"]
11681173

11691174

1175+
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
11701176
class TestAutoSchemaAllowsFilters(object):
11711177
class MockAPIView(APIView):
11721178
filter_backends = [filters.OrderingFilter]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy