Skip to content

Doctest fails in stdtypes.rst#106446

@CharlieZhao95

Description

@CharlieZhao95

Documentation

When some codes are modified, the doc and doctests are not updated synchronously.

Local doctest:

./python -m doctest ./Doc/library/stdtypes.rst
Details

********************************************************************** File "./Doc/library/stdtypes.rst", line 3769, in stdtypes.rst Failed example: v[1:4] Expected: <memory at 0x7f3ddc9f4350> Got: <memory at 0x7f42c250f040>********************************************************************** File "./Doc/library/stdtypes.rst", line 3952, in stdtypes.rst Failed example: mm.tolist() Expected: [89, 98, 99] Got: [97, 98, 99] ********************************************************************** File "./Doc/library/stdtypes.rst", line 4037, in stdtypes.rst Failed example: x[0] = b'a' Expected: Traceback (most recent call last): File "<stdin>", line 1, in<module> ValueError: memoryview: invalid value for format "B" Got: Traceback (most recent call last): File "/home/github/cpython/Lib/doctest.py", line 1357, in __run exec(compile(example.source, filename, "single", File "<doctest stdtypes.rst[234]>", line 1, in<module> x[0] = b'a'~^^^ TypeError: memoryview: invalid typefor format 'B'********************************************************************** File "./Doc/library/stdtypes.rst", line 4789, in stdtypes.rst Failed example: keys ^{'sausage', 'juice'} Expected:{'juice', 'sausage', 'bacon', 'spam'} Got:{'spam', 'sausage', 'bacon', 'juice'} ********************************************************************** File "./Doc/library/stdtypes.rst", line 4791, in stdtypes.rst Failed example: keys | ['juice', 'juice', 'juice'] Expected:{'juice', 'sausage', 'bacon', 'spam', 'eggs'} Got:{'spam', 'bacon', 'juice'} ********************************************************************** File "./Doc/library/stdtypes.rst", line 4997, in stdtypes.rst Failed example: dict[str][str] Expected: Traceback (most recent call last): File "<stdin>", line 1, in<module> TypeError: There are no type variables left in dict[str] Got: Traceback (most recent call last): File "/home/github/cpython/Lib/doctest.py", line 1357, in __run exec(compile(example.source, filename, "single", File "<doctest stdtypes.rst[335]>", line 1, in<module> dict[str][str] ~~~~~~~~~^^^^^ TypeError: dict[str] is not a generic class ********************************************************************** File "./Doc/library/stdtypes.rst", line 5209, in stdtypes.rst Failed example: isinstance(1, int | list[int]) Expected: Traceback (most recent call last): File "<stdin>", line 1, in<module> TypeError: isinstance() argument 2 cannot contain a parameterized generic Got: True ********************************************************************** File "./Doc/library/stdtypes.rst", line 5514, in stdtypes.rst Failed example: int.__subclasses__() Expected: [<class 'bool'>] Got: [<class 'bool'>, <enum 'IntEnum'>, <flag 'IntFlag'>, <class 're._constants._NamedIntConstant'>] ********************************************************************** File "./Doc/library/stdtypes.rst", line 5548, in stdtypes.rst Failed example: _ = int('2'* 5432) Expected: Traceback (most recent call last): ... ValueError: Exceeds the limit (4300 digits) for integer string conversion: value has 5432 digits; use sys.set_int_max_str_digits() to increase the limit. Got: Traceback (most recent call last): File "/home/github/cpython/Lib/doctest.py", line 1357, in __run exec(compile(example.source, filename, "single", File "<doctest stdtypes.rst[361]>", line 1, in<module> _ = int('2'* 5432) ^^^^^^^^^^^^^^^ ValueError: Exceeds the limit (4300 digits) for integer string conversion: value has 5432 digits; use sys.set_int_max_str_digits() to increase the limit ********************************************************************** File "./Doc/library/stdtypes.rst", line 5556, in stdtypes.rst Failed example: len(str(i_squared)) Expected: Traceback (most recent call last): ... ValueError: Exceeds the limit (4300 digits) for integer string conversion: value has 8599 digits; use sys.set_int_max_str_digits() to increase the limit. Got: Traceback (most recent call last): File "/home/github/cpython/Lib/doctest.py", line 1357, in __run exec(compile(example.source, filename, "single", File "<doctest stdtypes.rst[365]>", line 1, in<module> len(str(i_squared)) ^^^^^^^^^^^^^^ ValueError: Exceeds the limit (4300 digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit **********************************************************************

1 items had failures: 10 of 374 in stdtypes.rst ***Test Failed*** 10 failures.

BTW, It seems that all doctests are passing in the CI pipeline. Those failed cases are not found by CI doctest.
See: https://github.com/CharlieZhao95/cpython/actions/runs/5461321900/jobs/9939195566

... Document: library/stdtypes -------------------------- 1 items passed all tests: 50 tests in default 50 tests in 1 items. 50 passed and 0 failed. Test passed.

Environment:

CPython versions tested on: 3.13.0a0
Operating system and architecture: Ubuntu 22.04.1 LTS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions