mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix testcases for singledispatch are sometimes failed
They are sometimes failed with python3.5 because the order of singledispatch functions is not stable on python 3.5. This uses comparision via "in" keyword to check the signature of singledispatch functions stably.
This commit is contained in:
parent
242c63dc8b
commit
218de39462
@ -1832,19 +1832,26 @@ def test_autodoc_for_egged_code(app):
|
|||||||
def test_singledispatch(app):
|
def test_singledispatch(app):
|
||||||
options = {"members": None}
|
options = {"members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.singledispatch', options)
|
actual = do_autodoc(app, 'module', 'target.singledispatch', options)
|
||||||
assert list(actual) == [
|
if sys.version_info < (3, 6):
|
||||||
'',
|
# check the result via "in" because the order of singledispatch signatures is
|
||||||
'.. py:module:: target.singledispatch',
|
# 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
|
||||||
'.. py:function:: func(arg, kwarg=None)',
|
assert ' func(arg: str, kwarg=None)' in actual
|
||||||
' func(arg: int, kwarg=None)',
|
else:
|
||||||
' func(arg: str, kwarg=None)',
|
assert list(actual) == [
|
||||||
' :module: target.singledispatch',
|
'',
|
||||||
'',
|
'.. py:module:: target.singledispatch',
|
||||||
' A function for general use.',
|
'',
|
||||||
'',
|
'',
|
||||||
]
|
'.. 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),
|
@pytest.mark.skipif(sys.version_info < (3, 8),
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from test_ext_autodoc import do_autodoc
|
from test_ext_autodoc import do_autodoc
|
||||||
@ -108,16 +110,23 @@ def test_decorated(app):
|
|||||||
def test_singledispatch(app):
|
def test_singledispatch(app):
|
||||||
options = {}
|
options = {}
|
||||||
actual = do_autodoc(app, 'function', 'target.singledispatch.func', options)
|
actual = do_autodoc(app, 'function', 'target.singledispatch.func', options)
|
||||||
assert list(actual) == [
|
if sys.version_info < (3, 6):
|
||||||
'',
|
# check the result via "in" because the order of singledispatch signatures is
|
||||||
'.. py:function:: func(arg, kwarg=None)',
|
# usually changed (because dict is not OrderedDict yet!)
|
||||||
' func(arg: int, kwarg=None)',
|
assert '.. py:function:: func(arg, kwarg=None)' in actual
|
||||||
' func(arg: str, kwarg=None)',
|
assert ' func(arg: int, kwarg=None)' in actual
|
||||||
' :module: target.singledispatch',
|
assert ' func(arg: str, kwarg=None)' in actual
|
||||||
'',
|
else:
|
||||||
' A function for general use.',
|
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.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
|
Loading…
Reference in New Issue
Block a user