Skip to content

Commit 501abc6

Browse files
authored
Merge pull request #9478 from tk0miya/9443
Fix testcases that failed in python3.10.0b4
2 parents 9a2c3c4 + 0565da6 commit 501abc6

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

tests/test_ext_autodoc.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,16 +1398,9 @@ def test_slots(app):
13981398
def test_enum_class(app):
13991399
options = {"members": None}
14001400
actual = do_autodoc(app, 'class', 'target.enums.EnumCls', options)
1401-
1402-
if sys.version_info < (3, 10):
1403-
sig = '(value)'
1404-
else:
1405-
sig = ('(value, names=None, *, module=None, qualname=None, type=None, start=1, '
1406-
'boundary=None)')
1407-
14081401
assert list(actual) == [
14091402
'',
1410-
'.. py:class:: EnumCls%s' % sig,
1403+
'.. py:class:: EnumCls(value)',
14111404
' :module: target.enums',
14121405
'',
14131406
' this is enum class',

tests/test_util_inspect.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,8 @@ def test_signature_annotations():
215215

216216
# optional union
217217
sig = inspect.signature(f20)
218-
if sys.version_info < (3, 7):
219-
assert stringify_signature(sig) in ('() -> Optional[Union[int, str]]',
220-
'() -> Optional[Union[str, int]]')
221-
else:
222-
assert stringify_signature(sig) == '() -> Optional[Union[int, str]]'
218+
assert stringify_signature(sig) in ('() -> Optional[Union[int, str]]',
219+
'() -> Optional[Union[str, int]]')
223220

224221
# Any
225222
sig = inspect.signature(f14)

tests/test_util_typing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ def test_restify_type_Literal():
142142

143143
@pytest.mark.skipif(sys.version_info < (3, 10), reason='python 3.10+ is required.')
144144
def test_restify_type_union_operator():
145-
assert restify(int | None) == "Optional[:class:`int`]" # type: ignore
145+
assert restify(int | None) == ":class:`int` | :obj:`None`" # type: ignore
146146
assert restify(int | str) == ":class:`int` | :class:`str`" # type: ignore
147-
assert restify(int | str | None) == "Optional[:class:`int` | :class:`str`]" # type: ignore
147+
assert restify(int | str | None) == ":class:`int` | :class:`str` | :obj:`None`" # type: ignore
148148

149149

150150
def test_restify_broken_type_hints():
@@ -253,9 +253,9 @@ def test_stringify_type_Literal():
253253

254254
@pytest.mark.skipif(sys.version_info < (3, 10), reason='python 3.10+ is required.')
255255
def test_stringify_type_union_operator():
256-
assert stringify(int | None) == "Optional[int]" # type: ignore
256+
assert stringify(int | None) == "int | None" # type: ignore
257257
assert stringify(int | str) == "int | str" # type: ignore
258-
assert stringify(int | str | None) == "Optional[int | str]" # type: ignore
258+
assert stringify(int | str | None) == "int | str | None" # type: ignore
259259

260260

261261
def test_stringify_broken_type_hints():

0 commit comments

Comments
 (0)