From 0e5cb69449c19871e86b6e211642f553c2317d33 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 14 Sep 2017 11:30:45 +0200 Subject: [PATCH] Adjust test case --- tests/test_schemas.py | 61 +++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 4a621f74c..f8a63aa89 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -15,6 +15,7 @@ from rest_framework.schemas import ( AutoSchema, ManualSchema, SchemaGenerator, get_schema_view ) from rest_framework.test import APIClient, APIRequestFactory +from rest_framework.utils import formatting from rest_framework.views import APIView from rest_framework.viewsets import ModelViewSet @@ -579,44 +580,36 @@ class TestDescriptor(TestCase): assert link == expected +def test_docstring_is_not_stripped_by_get_description(): + class ExampleDocstringAPIView(APIView): + """ + === title -class ExampleDocstringAPIView(APIView): - """ -=== title + * item a + * item a-a + * item a-b + * item b - * item a - * item a-a - * item a-b - * item b + - item 1 + - item 2 - - item 1 - - item 2 + code block begin + code + code + code + code block end - code block begin - code - code - code - code block end + the end + """ -the end -""" + def get(self, *args, **kwargs): + pass - def get(self, *args, **kwargs): - pass + def post(self, request, *args, **kwargs): + pass - def post(self, request, *args, **kwargs): - pass - - -class TestDocstringIsNotStrippedByGetDescription(TestCase): - 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] \ No newline at end of file + 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 == formatting.dedent(ExampleDocstringAPIView.__doc__[1:][:-1])