mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 11:04:02 +03:00
Skip coreapi tests in GenerateSchemaTests if coreapi is not installed (#9229)
This commit is contained in:
parent
c4f9d432dd
commit
552a67acde
|
@ -8,7 +8,7 @@ from django.test import TestCase
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from rest_framework.compat import uritemplate, yaml
|
from rest_framework.compat import coreapi, uritemplate, yaml
|
||||||
from rest_framework.management.commands import generateschema
|
from rest_framework.management.commands import generateschema
|
||||||
from rest_framework.utils import formatting, json
|
from rest_framework.utils import formatting, json
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
@ -91,6 +91,7 @@ class GenerateSchemaTests(TestCase):
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
@pytest.mark.skipif(yaml is None, reason='PyYAML is required.')
|
@pytest.mark.skipif(yaml is None, reason='PyYAML is required.')
|
||||||
|
@pytest.mark.skipif(coreapi is None, reason='coreapi is required.')
|
||||||
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'})
|
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'})
|
||||||
def test_coreapi_renders_default_schema_with_custom_title_url_and_description(self):
|
def test_coreapi_renders_default_schema_with_custom_title_url_and_description(self):
|
||||||
expected_out = """info:
|
expected_out = """info:
|
||||||
|
@ -113,6 +114,7 @@ class GenerateSchemaTests(TestCase):
|
||||||
|
|
||||||
self.assertIn(formatting.dedent(expected_out), self.out.getvalue())
|
self.assertIn(formatting.dedent(expected_out), self.out.getvalue())
|
||||||
|
|
||||||
|
@pytest.mark.skipif(coreapi is None, reason='coreapi is required.')
|
||||||
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'})
|
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'})
|
||||||
def test_coreapi_renders_openapi_json_schema(self):
|
def test_coreapi_renders_openapi_json_schema(self):
|
||||||
expected_out = {
|
expected_out = {
|
||||||
|
@ -142,6 +144,7 @@ class GenerateSchemaTests(TestCase):
|
||||||
|
|
||||||
self.assertDictEqual(out_json, expected_out)
|
self.assertDictEqual(out_json, expected_out)
|
||||||
|
|
||||||
|
@pytest.mark.skipif(coreapi is None, reason='coreapi is required.')
|
||||||
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'})
|
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'})
|
||||||
def test_renders_corejson_schema(self):
|
def test_renders_corejson_schema(self):
|
||||||
expected_out = """{"_type":"document","":{"list":{"_type":"link","url":"/","action":"get"}}}"""
|
expected_out = """{"_type":"document","":{"list":{"_type":"link","url":"/","action":"get"}}}"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user