From 6d5e43a0ffc99830c91e37c026d89a6d70fe52c8 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 6 Nov 2020 01:36:04 +0900 Subject: Drop code for supporting py35 --- tests/test_ext_autodoc.py | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'tests/test_ext_autodoc.py') diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py index 703cc13f6..bc3d07660 100644 --- a/tests/test_ext_autodoc.py +++ b/tests/test_ext_autodoc.py @@ -290,7 +290,6 @@ def test_format_signature(app): '(b, c=42, *d, **e)' -@pytest.mark.skipif(sys.version_info < (3, 5), reason='typing is available since python3.5.') @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_process_signature_typing_generic(app): actual = do_autodoc(app, 'class', 'target.generic_class.A', {}) @@ -1559,7 +1558,6 @@ def test_partialmethod_undoc_members(app): assert list(actual) == expected -@pytest.mark.skipif(sys.version_info < (3, 6), reason='py36+ is available since python3.6.') @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_typed_instance_variables(app): options = {"members": None, @@ -1653,7 +1651,6 @@ def test_autodoc_typed_instance_variables(app): ] -@pytest.mark.skipif(sys.version_info < (3, 6), reason='py36+ is available since python3.6.') @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_typed_inherited_instance_variables(app): options = {"members": None, @@ -1783,7 +1780,6 @@ def test_autodoc_Annotated(app): ] -@pytest.mark.skipif(sys.version_info < (3, 6), reason='py36+ is required.') @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_TYPE_CHECKING(app): options = {"members": None, @@ -1832,26 +1828,19 @@ def test_autodoc_for_egged_code(app): def test_singledispatch(app): options = {"members": None} actual = do_autodoc(app, 'module', 'target.singledispatch', options) - if sys.version_info < (3, 6): - # check the result via "in" because the order of singledispatch signatures is - # usually changed (because dict is not OrderedDict yet!) - assert '.. py:function:: func(arg, kwarg=None)' in actual - assert ' func(arg: int, kwarg=None)' in actual - assert ' func(arg: str, kwarg=None)' in actual - else: - assert list(actual) == [ - '', - '.. py:module:: target.singledispatch', - '', - '', - '.. py:function:: func(arg, kwarg=None)', - ' func(arg: int, kwarg=None)', - ' func(arg: str, kwarg=None)', - ' :module: target.singledispatch', - '', - ' A function for general use.', - '', - ] + assert list(actual) == [ + '', + '.. py:module:: target.singledispatch', + '', + '', + '.. py:function:: func(arg, kwarg=None)', + ' func(arg: int, kwarg=None)', + ' func(arg: str, kwarg=None)', + ' :module: target.singledispatch', + '', + ' A function for general use.', + '', + ] @pytest.mark.skipif(sys.version_info < (3, 8), -- cgit v1.2.1 From a39cf57717a684bcd7fc81833a73397593a412d7 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 24 Feb 2021 22:51:06 +0900 Subject: Close #8924: autodoc: Support `bound` argument for TypeVar --- tests/test_ext_autodoc.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/test_ext_autodoc.py') diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py index d657ead60..d9986e9ca 100644 --- a/tests/test_ext_autodoc.py +++ b/tests/test_ext_autodoc.py @@ -1993,6 +1993,14 @@ def test_autodoc_TypeVar(app): '', ' alias of :class:`int`', '', + '', + '.. py:data:: T7', + ' :module: target.typevar', + '', + ' T7', + '', + " alias of TypeVar('T7', bound=\\ :class:`int`)", + '', ] -- cgit v1.2.1 From 75f5122996ea7eb340d31bb3006efde7d2a351f6 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 11 Mar 2021 02:01:17 +0900 Subject: Fix #7383: autodoc: Support typehints for properties py:property directive now outputs py:property directive to describe its type annotation. --- tests/test_ext_autodoc.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'tests/test_ext_autodoc.py') diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py index d9986e9ca..7c6f4e0d6 100644 --- a/tests/test_ext_autodoc.py +++ b/tests/test_ext_autodoc.py @@ -1033,9 +1033,8 @@ def test_autodoc_descriptor(app): ' Descriptor instance docstring.', '', '', - ' .. py:method:: Class.prop', + ' .. py:property:: Class.prop', ' :module: target.descriptor', - ' :property:', '', ' Property.', '' @@ -1055,9 +1054,8 @@ def test_autodoc_cached_property(app): ' :module: target.cached_property', '', '', - ' .. py:method:: Foo.prop', + ' .. py:property:: Foo.prop', ' :module: target.cached_property', - ' :property:', '', ] @@ -1516,10 +1514,9 @@ def test_abstractmethods(app): ' :module: target.abstractmethods', '', '', - ' .. py:method:: Base.prop', + ' .. py:property:: Base.prop', ' :module: target.abstractmethods', ' :abstractmethod:', - ' :property:', '', '', ' .. py:method:: Base.staticmeth()', -- cgit v1.2.1 From cb654d287b0296a5acc539f962c7ef1ecc4a523f Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 21 Mar 2021 00:52:49 +0900 Subject: Rename DocumenterBridge.filename_set to record_dependencies DocumenterBridge.filename_set has been used since its beginning. On the other hand, in docutils, record_dependencies attribute is well-used to store the list of dependency files. So this renames it to docutils' standard attribute. --- tests/test_ext_autodoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_ext_autodoc.py') diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py index 7c6f4e0d6..8ea799f49 100644 --- a/tests/test_ext_autodoc.py +++ b/tests/test_ext_autodoc.py @@ -68,7 +68,7 @@ def make_directive_bridge(env): env = env, genopt = options, result = ViewList(), - filename_set = set(), + record_dependencies = set(), state = Mock(), ) directive.state.document.settings.tab_width = 8 -- cgit v1.2.1 From acf66bc4d5b53189f893a50a235e710f063d629d Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 22 Mar 2021 01:33:37 +0900 Subject: Close #5603: autodoc: Allow to refer to a python object using canonical name This generates `:canonical:` option for `:py:class:` directive if the target class is imported from other module. It allows users to refer it using both the new name (imported name) and the original name (canonical name). It helps a library that implements some class in private module (like `_io.StringIO`), and publish it as public module (like `io.StringIO`). --- tests/test_ext_autodoc.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/test_ext_autodoc.py') diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py index 8ea799f49..824ee77c2 100644 --- a/tests/test_ext_autodoc.py +++ b/tests/test_ext_autodoc.py @@ -2474,3 +2474,34 @@ def test_hide_value(app): ' :meta hide-value:', '', ] + + +@pytest.mark.sphinx('html', testroot='ext-autodoc') +def test_canonical(app): + options = {'members': None, + 'imported-members': None} + actual = do_autodoc(app, 'module', 'target.canonical', options) + assert list(actual) == [ + '', + '.. py:module:: target.canonical', + '', + '', + '.. py:class:: Bar()', + ' :module: target.canonical', + '', + ' docstring', + '', + '', + '.. py:class:: Foo()', + ' :module: target.canonical', + ' :canonical: target.canonical.original.Foo', + '', + ' docstring', + '', + '', + ' .. py:method:: Foo.meth()', + ' :module: target.canonical', + '', + ' docstring', + '', + ] -- cgit v1.2.1