Skip to content

Commit 552a67a

Browse files
authored
Skip coreapi tests in GenerateSchemaTests if coreapi is not installed (#9229)
1 parent c4f9d43 commit 552a67a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/schemas/test_managementcommand.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.test.utils import override_settings
99
from django.urls import path
1010

11-
from rest_framework.compat import uritemplate, yaml
11+
from rest_framework.compat import coreapi, uritemplate, yaml
1212
from rest_framework.management.commands import generateschema
1313
from rest_framework.utils import formatting, json
1414
from rest_framework.views import APIView
@@ -91,6 +91,7 @@ def test_writes_schema_to_file_on_parameter(self):
9191
os.remove(path)
9292

9393
@pytest.mark.skipif(yaml is None, reason='PyYAML is required.')
94+
@pytest.mark.skipif(coreapi is None, reason='coreapi is required.')
9495
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'})
9596
def test_coreapi_renders_default_schema_with_custom_title_url_and_description(self):
9697
expected_out = """info:
@@ -113,6 +114,7 @@ def test_coreapi_renders_default_schema_with_custom_title_url_and_description(se
113114

114115
self.assertIn(formatting.dedent(expected_out), self.out.getvalue())
115116

117+
@pytest.mark.skipif(coreapi is None, reason='coreapi is required.')
116118
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'})
117119
def test_coreapi_renders_openapi_json_schema(self):
118120
expected_out = {
@@ -142,6 +144,7 @@ def test_coreapi_renders_openapi_json_schema(self):
142144

143145
self.assertDictEqual(out_json, expected_out)
144146

147+
@pytest.mark.skipif(coreapi is None, reason='coreapi is required.')
145148
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'})
146149
def test_renders_corejson_schema(self):
147150
expected_out = """{"_type":"document","":{"list":{"_type":"link","url":"/","action":"get"}}}"""

0 commit comments

Comments
 (0)