mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Adjust test case
This commit is contained in:
parent
6f0bbe1438
commit
0e5cb69449
|
@ -15,6 +15,7 @@ from rest_framework.schemas import (
|
||||||
AutoSchema, ManualSchema, SchemaGenerator, get_schema_view
|
AutoSchema, ManualSchema, SchemaGenerator, get_schema_view
|
||||||
)
|
)
|
||||||
from rest_framework.test import APIClient, APIRequestFactory
|
from rest_framework.test import APIClient, APIRequestFactory
|
||||||
|
from rest_framework.utils import formatting
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
|
@ -579,44 +580,36 @@ class TestDescriptor(TestCase):
|
||||||
assert link == expected
|
assert link == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_docstring_is_not_stripped_by_get_description():
|
||||||
|
class ExampleDocstringAPIView(APIView):
|
||||||
|
"""
|
||||||
|
=== title
|
||||||
|
|
||||||
class ExampleDocstringAPIView(APIView):
|
* item a
|
||||||
"""
|
* item a-a
|
||||||
=== title
|
* item a-b
|
||||||
|
* item b
|
||||||
|
|
||||||
* item a
|
- item 1
|
||||||
* item a-a
|
- item 2
|
||||||
* item a-b
|
|
||||||
* item b
|
|
||||||
|
|
||||||
- item 1
|
code block begin
|
||||||
- item 2
|
code
|
||||||
|
code
|
||||||
|
code
|
||||||
|
code block end
|
||||||
|
|
||||||
code block begin
|
the end
|
||||||
code
|
"""
|
||||||
code
|
|
||||||
code
|
|
||||||
code block end
|
|
||||||
|
|
||||||
the end
|
def get(self, *args, **kwargs):
|
||||||
"""
|
pass
|
||||||
|
|
||||||
def get(self, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
view = ExampleDocstringAPIView()
|
||||||
pass
|
schema = view.schema
|
||||||
|
descr = schema.get_description('example', 'get')
|
||||||
|
# the first and last character are '\n' correctly removed by get_description
|
||||||
class TestDocstringIsNotStrippedByGetDescription(TestCase):
|
assert descr == formatting.dedent(ExampleDocstringAPIView.__doc__[1:][:-1])
|
||||||
def setUp(self):
|
|
||||||
self.patterns = [
|
|
||||||
url('^example/?$', ExampleDocstringAPIView.as_view()),
|
|
||||||
]
|
|
||||||
|
|
||||||
def test_docstring(self):
|
|
||||||
view = ExampleDocstringAPIView()
|
|
||||||
schema = view.schema
|
|
||||||
descr = schema.get_description('example', 'get')
|
|
||||||
# the first and last character are '\n' correctly removed by get_description
|
|
||||||
assert descr == ExampleDocstringAPIView.__doc__[1:][:-1]
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user