From 22fafb9773e3e78b05072909c019d70545cf9226 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Fri, 24 Apr 2020 15:15:22 +0100 Subject: Support singledispatch in autofunction/methodThis makes autofunction and automethod work standalone withsingledispatch functions and methods. Previously only automodule wouldsupport these --- tests/test_autodoc.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/test_autodoc.py') diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index dd474536d..8e23291f3 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -1604,6 +1604,21 @@ def test_singledispatch(): ] +@pytest.mark.usefixtures('setup_test') +def test_singledispatch_autofunction(): + options = {} + actual = do_autodoc(app, 'function', 'target.singledispatch.func', options) + assert list(actual) == [ + '', + '.. 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), reason='singledispatchmethod is available since python3.8') @pytest.mark.usefixtures('setup_test') @@ -1631,6 +1646,23 @@ def test_singledispatchmethod(): ] +@pytest.mark.skipif(sys.version_info < (3, 8), + reason='singledispatchmethod is available since python3.8') +@pytest.mark.usefixtures('setup_test') +def test_singledispatchmethod_automethod(): + options = {} + actual = do_autodoc(app, 'method', 'target.singledispatchmethod.Foo.meth', options) + assert list(actual) == [ + '', + '.. py:method:: Foo.meth(arg, kwarg=None)', + ' Foo.meth(arg: int, kwarg=None)', + ' Foo.meth(arg: str, kwarg=None)', + ' :module: target.singledispatchmethod', + '', + ' A method for general use.', + '', + ] + @pytest.mark.usefixtures('setup_test') @pytest.mark.skipif(pyximport is None, reason='cython is not installed') def test_cython(): -- cgit v1.2.1