88from django .test .utils import override_settings
99from django .urls import path
1010
11- from rest_framework .compat import uritemplate , yaml
11+ from rest_framework .compat import coreapi , uritemplate , yaml
1212from rest_framework .management .commands import generateschema
1313from rest_framework .utils import formatting , json
1414from rest_framework .views import APIView
@@ -35,20 +35,23 @@ def get_schema(self, **kwargs):
3535
3636
3737@override_settings (ROOT_URLCONF = __name__ )
38+ @pytest .mark .skipif (not coreapi , reason = 'coreapi is not installed' )
3839@pytest .mark .skipif (not uritemplate , reason = 'uritemplate is not installed' )
3940class GenerateSchemaTests (TestCase ):
4041 """Tests for management command generateschema."""
4142
4243 def setUp (self ):
4344 self .out = io .StringIO ()
4445
46+ @pytest .mark .skipif (not coreapi , reason = 'coreapi is not installed' )
4547 def test_command_detects_schema_generation_mode (self ):
4648 """Switching between CoreAPI & OpenAPI"""
4749 command = generateschema .Command ()
4850 assert command .get_mode () == generateschema .OPENAPI_MODE
4951 with override_settings (REST_FRAMEWORK = {'DEFAULT_SCHEMA_CLASS' : 'rest_framework.schemas.AutoSchema' }):
5052 assert command .get_mode () == generateschema .COREAPI_MODE
5153
54+ @pytest .mark .skipif (not coreapi , reason = 'coreapi is not installed' )
5255 @pytest .mark .skipif (yaml is None , reason = 'PyYAML is required.' )
5356 def test_renders_default_schema_with_custom_title_url_and_description (self ):
5457 call_command ('generateschema' ,
@@ -91,6 +94,7 @@ def test_writes_schema_to_file_on_parameter(self):
9194 os .remove (path )
9295
9396 @pytest .mark .skipif (yaml is None , reason = 'PyYAML is required.' )
97+ @pytest .mark .skipif (not coreapi , reason = 'coreapi is not installed' )
9498 @override_settings (REST_FRAMEWORK = {'DEFAULT_SCHEMA_CLASS' : 'rest_framework.schemas.AutoSchema' })
9599 def test_coreapi_renders_default_schema_with_custom_title_url_and_description (self ):
96100 expected_out = """info:
@@ -113,6 +117,7 @@ def test_coreapi_renders_default_schema_with_custom_title_url_and_description(se
113117
114118 self .assertIn (formatting .dedent (expected_out ), self .out .getvalue ())
115119
120+ @pytest .mark .skipif (not coreapi , reason = 'coreapi is not installed' )
116121 @override_settings (REST_FRAMEWORK = {'DEFAULT_SCHEMA_CLASS' : 'rest_framework.schemas.AutoSchema' })
117122 def test_coreapi_renders_openapi_json_schema (self ):
118123 expected_out = {
@@ -142,6 +147,7 @@ def test_coreapi_renders_openapi_json_schema(self):
142147
143148 self .assertDictEqual (out_json , expected_out )
144149
150+ @pytest .mark .skipif (not coreapi , reason = 'coreapi is not installed' )
145151 @override_settings (REST_FRAMEWORK = {'DEFAULT_SCHEMA_CLASS' : 'rest_framework.schemas.AutoSchema' })
146152 def test_renders_corejson_schema (self ):
147153 expected_out = """{"_type":"document","":{"list":{"_type":"link","url":"/","action":"get"}}}"""
0 commit comments