<s> """<STR_LIT>""" <EOL> from collections import namedtuple <EOL> from inspect import cleandoc <EOL> from textwrap import dedent <EOL> from unittest import TestCase <EOL> from sphinx . ext . napoleon import Config <EOL> from sphinx . ext . napoleon . docstring import GoogleDocstring , NumpyDocstring <EOL> from util import mock <EOL> class NamedtupleSubclass ( namedtuple ( '<STR_LIT>' , ( '<STR_LIT>' , '<STR_LIT>' ) ) ) : <EOL> """<STR_LIT>""" <EOL> __slots__ = ( ) <EOL> def __new__ ( cls , attr1 , attr2 = None ) : <EOL> return super ( NamedtupleSubclass , cls ) . __new__ ( cls , attr1 , attr2 ) <EOL> class BaseDocstringTest ( TestCase ) : <EOL> pass <EOL> class NamedtupleSubclassTest ( BaseDocstringTest ) : <EOL> def test_attributes_docstring ( self ) : <EOL> config = Config ( ) <EOL> actual = str ( NumpyDocstring ( cleandoc ( NamedtupleSubclass . __doc__ ) , <EOL> config = config , app = None , what = '<STR_LIT:class>' , <EOL> name = '<STR_LIT>' , obj = NamedtupleSubclass ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) <EOL> class GoogleDocstringTest ( BaseDocstringTest ) : <EOL> docstrings = [ ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) ] <EOL> def test_docstrings ( self ) : <EOL> config = Config ( <EOL> napoleon_use_param = False , <EOL> napoleon_use_rtype = False , <EOL> napoleon_use_keyword = False <EOL> ) <EOL> for docstring , expected in self . docstrings : <EOL> actual = str ( GoogleDocstring ( dedent ( docstring ) , config ) ) <EOL> expected = dedent ( expected ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_parameters_with_class_reference ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> actual = str ( GoogleDocstring ( docstring ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) <EOL> def test_attributes_with_class_reference ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> actual = str ( GoogleDocstring ( docstring ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) <EOL> docstring = """<STR_LIT>""" <EOL> actual = str ( GoogleDocstring ( docstring ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) <EOL> def test_code_block_in_returns_section ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> expected = """<STR_LIT>""" <EOL> actual = str ( GoogleDocstring ( docstring ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_colon_in_return_type ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> expected = """<STR_LIT>""" <EOL> actual = str ( GoogleDocstring ( docstring ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_xrefs_in_return_type ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> expected = """<STR_LIT>""" <EOL> actual = str ( GoogleDocstring ( docstring ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_raises_types ( self ) : <EOL> docstrings = [ ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" <EOL> """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" <EOL> """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" <EOL> """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) ] <EOL> for docstring , expected in docstrings : <EOL> actual = str ( GoogleDocstring ( docstring ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_kwargs_in_arguments ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> expected = """<STR_LIT>""" <EOL> actual = str ( GoogleDocstring ( docstring ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_section_header_formatting ( self ) : <EOL> docstrings = [ ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) ] <EOL> for docstring , expected in docstrings : <EOL> actual = str ( GoogleDocstring ( docstring ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_list_in_parameter_description ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> expected = """<STR_LIT>""" <EOL> config = Config ( napoleon_use_param = True ) <EOL> actual = str ( GoogleDocstring ( docstring , config ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> expected = """<STR_LIT>""" <EOL> config = Config ( napoleon_use_param = False ) <EOL> actual = str ( GoogleDocstring ( docstring , config ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> class NumpyDocstringTest ( BaseDocstringTest ) : <EOL> docstrings = [ ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) ] <EOL> def test_docstrings ( self ) : <EOL> config = Config ( <EOL> napoleon_use_param = False , <EOL> napoleon_use_rtype = False , <EOL> napoleon_use_keyword = False ) <EOL> for docstring , expected in self . docstrings : <EOL> actual = str ( NumpyDocstring ( dedent ( docstring ) , config ) ) <EOL> expected = dedent ( expected ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_parameters_with_class_reference ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> config = Config ( napoleon_use_param = False ) <EOL> actual = str ( NumpyDocstring ( docstring , config ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) <EOL> config = Config ( napoleon_use_param = True ) <EOL> actual = str ( NumpyDocstring ( docstring , config ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) <EOL> def test_parameters_without_class_reference ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> config = Config ( napoleon_use_param = False ) <EOL> actual = str ( NumpyDocstring ( docstring , config ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) <EOL> config = Config ( napoleon_use_param = True ) <EOL> actual = str ( NumpyDocstring ( dedent ( docstring ) , config ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) <EOL> def test_see_also_refs ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> actual = str ( NumpyDocstring ( docstring ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) <EOL> docstring = """<STR_LIT>""" <EOL> config = Config ( ) <EOL> app = mock . Mock ( ) <EOL> actual = str ( NumpyDocstring ( docstring , config , app , "<STR_LIT>" ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) <EOL> def test_colon_in_return_type ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> expected = """<STR_LIT>""" <EOL> config = Config ( ) <EOL> app = mock . Mock ( ) <EOL> actual = str ( NumpyDocstring ( docstring , config , app , "<STR_LIT>" ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_underscore_in_attribute ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> expected = """<STR_LIT>""" <EOL> config = Config ( napoleon_use_ivar = True ) <EOL> app = mock . Mock ( ) <EOL> actual = str ( NumpyDocstring ( docstring , config , app , "<STR_LIT:class>" ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_raises_types ( self ) : <EOL> docstrings = [ ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" <EOL> """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" <EOL> """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) ] <EOL> for docstring , expected in docstrings : <EOL> config = Config ( ) <EOL> app = mock . Mock ( ) <EOL> actual = str ( NumpyDocstring ( docstring , config , app , "<STR_LIT>" ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_xrefs_in_return_type ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> expected = """<STR_LIT>""" <EOL> config = Config ( ) <EOL> app = mock . Mock ( ) <EOL> actual = str ( NumpyDocstring ( docstring , config , app , "<STR_LIT>" ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_section_header_underline_length ( self ) : <EOL> docstrings = [ ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) , <EOL> ( """<STR_LIT>""" , """<STR_LIT>""" ) ] <EOL> for docstring , expected in docstrings : <EOL> actual = str ( NumpyDocstring ( docstring ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_list_in_parameter_description ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> expected = """<STR_LIT>""" <EOL> config = Config ( napoleon_use_param = True ) <EOL> actual = str ( NumpyDocstring ( docstring , config ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> expected = """<STR_LIT>""" <EOL> config = Config ( napoleon_use_param = False ) <EOL> actual = str ( NumpyDocstring ( docstring , config ) ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_keywords_with_types ( self ) : <EOL> docstring = """<STR_LIT>""" <EOL> actual = str ( GoogleDocstring ( docstring ) ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( expected , actual ) </s>
