mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #9478 from tk0miya/9443
Fix testcases that failed in python3.10.0b4
This commit is contained in:
commit
501abc67b6
@ -1398,16 +1398,9 @@ def test_slots(app):
|
|||||||
def test_enum_class(app):
|
def test_enum_class(app):
|
||||||
options = {"members": None}
|
options = {"members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.enums.EnumCls', options)
|
actual = do_autodoc(app, 'class', 'target.enums.EnumCls', options)
|
||||||
|
|
||||||
if sys.version_info < (3, 10):
|
|
||||||
sig = '(value)'
|
|
||||||
else:
|
|
||||||
sig = ('(value, names=None, *, module=None, qualname=None, type=None, start=1, '
|
|
||||||
'boundary=None)')
|
|
||||||
|
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
'.. py:class:: EnumCls%s' % sig,
|
'.. py:class:: EnumCls(value)',
|
||||||
' :module: target.enums',
|
' :module: target.enums',
|
||||||
'',
|
'',
|
||||||
' this is enum class',
|
' this is enum class',
|
||||||
|
@ -215,11 +215,8 @@ def test_signature_annotations():
|
|||||||
|
|
||||||
# optional union
|
# optional union
|
||||||
sig = inspect.signature(f20)
|
sig = inspect.signature(f20)
|
||||||
if sys.version_info < (3, 7):
|
assert stringify_signature(sig) in ('() -> Optional[Union[int, str]]',
|
||||||
assert stringify_signature(sig) in ('() -> Optional[Union[int, str]]',
|
'() -> Optional[Union[str, int]]')
|
||||||
'() -> Optional[Union[str, int]]')
|
|
||||||
else:
|
|
||||||
assert stringify_signature(sig) == '() -> Optional[Union[int, str]]'
|
|
||||||
|
|
||||||
# Any
|
# Any
|
||||||
sig = inspect.signature(f14)
|
sig = inspect.signature(f14)
|
||||||
|
@ -142,9 +142,9 @@ def test_restify_type_Literal():
|
|||||||
|
|
||||||
@pytest.mark.skipif(sys.version_info < (3, 10), reason='python 3.10+ is required.')
|
@pytest.mark.skipif(sys.version_info < (3, 10), reason='python 3.10+ is required.')
|
||||||
def test_restify_type_union_operator():
|
def test_restify_type_union_operator():
|
||||||
assert restify(int | None) == "Optional[:class:`int`]" # type: ignore
|
assert restify(int | None) == ":class:`int` | :obj:`None`" # type: ignore
|
||||||
assert restify(int | str) == ":class:`int` | :class:`str`" # type: ignore
|
assert restify(int | str) == ":class:`int` | :class:`str`" # type: ignore
|
||||||
assert restify(int | str | None) == "Optional[:class:`int` | :class:`str`]" # type: ignore
|
assert restify(int | str | None) == ":class:`int` | :class:`str` | :obj:`None`" # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def test_restify_broken_type_hints():
|
def test_restify_broken_type_hints():
|
||||||
@ -253,9 +253,9 @@ def test_stringify_type_Literal():
|
|||||||
|
|
||||||
@pytest.mark.skipif(sys.version_info < (3, 10), reason='python 3.10+ is required.')
|
@pytest.mark.skipif(sys.version_info < (3, 10), reason='python 3.10+ is required.')
|
||||||
def test_stringify_type_union_operator():
|
def test_stringify_type_union_operator():
|
||||||
assert stringify(int | None) == "Optional[int]" # type: ignore
|
assert stringify(int | None) == "int | None" # type: ignore
|
||||||
assert stringify(int | str) == "int | str" # type: ignore
|
assert stringify(int | str) == "int | str" # type: ignore
|
||||||
assert stringify(int | str | None) == "Optional[int | str]" # type: ignore
|
assert stringify(int | str | None) == "int | str | None" # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def test_stringify_broken_type_hints():
|
def test_stringify_broken_type_hints():
|
||||||
|
Loading…
Reference in New Issue
Block a user