mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-08-11 13:34:59 -05:00
moved python 3.6+ syntax test data to standalone file
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
class PEP526Class:
|
||||
"""Sample class with PEP 526 annotations
|
||||
|
||||
Attributes:
|
||||
attr1: Attr1 description.
|
||||
attr2: Attr2 description.
|
||||
"""
|
||||
|
||||
attr1: int
|
||||
attr2: str
|
||||
@@ -13,6 +13,7 @@ import re
|
||||
from collections import namedtuple
|
||||
from contextlib import contextmanager
|
||||
from inspect import cleandoc
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
from unittest import TestCase, mock
|
||||
|
||||
@@ -23,6 +24,9 @@ from sphinx.ext.napoleon.docstring import (GoogleDocstring, NumpyDocstring,
|
||||
_convert_numpy_type_spec, _recombine_set_tokens,
|
||||
_token_type, _tokenize_type_spec)
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from ext_napoleon_docstring_data import PEP526Class
|
||||
|
||||
|
||||
class NamedtupleSubclass(namedtuple('NamedtupleSubclass', ('attr1', 'attr2'))):
|
||||
"""Sample namedtuple subclass
|
||||
@@ -45,18 +49,6 @@ class NamedtupleSubclass(namedtuple('NamedtupleSubclass', ('attr1', 'attr2'))):
|
||||
return super().__new__(cls, attr1, attr2)
|
||||
|
||||
|
||||
class PEP526Class:
|
||||
"""Sample class with PEP 526 annotations
|
||||
|
||||
Attributes:
|
||||
attr1: Attr1 description.
|
||||
attr2: Attr2 description.
|
||||
"""
|
||||
|
||||
attr1: int
|
||||
attr2: str
|
||||
|
||||
|
||||
class BaseDocstringTest(TestCase):
|
||||
pass
|
||||
|
||||
@@ -1105,13 +1097,13 @@ Do as you please
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_pep_526_annotations(self):
|
||||
config = Config(
|
||||
napoleon_google_attr_annotations=True
|
||||
)
|
||||
actual = str(GoogleDocstring(cleandoc(PEP526Class.__doc__), config, app=None, what="class",
|
||||
obj=PEP526Class))
|
||||
print(actual)
|
||||
expected = """\
|
||||
if sys.version_info >= (3, 6):
|
||||
config = Config(
|
||||
napoleon_google_attr_annotations=True
|
||||
)
|
||||
actual = str(GoogleDocstring(cleandoc(PEP526Class.__doc__), config, app=None, what="class",
|
||||
obj=PEP526Class))
|
||||
expected = """\
|
||||
Sample class with PEP 526 annotations
|
||||
|
||||
.. attribute:: attr1
|
||||
@@ -1126,7 +1118,7 @@ Sample class with PEP 526 annotations
|
||||
|
||||
:type: str
|
||||
"""
|
||||
self.assertEqual(expected, actual)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
||||
class NumpyDocstringTest(BaseDocstringTest):
|
||||
|
||||
Reference in New Issue
Block a user