Fix doctest for 3.13 (#12625)

This commit is contained in:
Max Muoto
2024-09-08 05:38:13 -05:00
committed by GitHub
parent 61ed105cdb
commit 089953ed84
2 changed files with 23 additions and 7 deletions

View File

@@ -1,9 +1,10 @@
import sys
import types
import unittest
from _typeshed import ExcInfo
from collections.abc import Callable
from typing import Any, NamedTuple
from typing_extensions import TypeAlias
from typing import Any, ClassVar, NamedTuple
from typing_extensions import Self, TypeAlias
__all__ = [
"register_optionflag",
@@ -41,9 +42,22 @@ __all__ = [
"debug",
]
class TestResults(NamedTuple):
failed: int
attempted: int
# MyPy errors on conditionals within named tuples.
if sys.version_info >= (3, 13):
class TestResults(NamedTuple):
def __new__(cls, failed: int, attempted: int, *, skipped: int = 0) -> Self: ... # type: ignore[misc]
skipped: int
failed: int
attempted: int
_fields: ClassVar = ("failed", "attempted") # type: ignore[misc]
__match_args__ = ("failed", "attempted") # type: ignore[misc]
__doc__: None # type: ignore[misc]
else:
class TestResults(NamedTuple):
failed: int
attempted: int
OPTIONFLAGS_BY_NAME: dict[str, int]
@@ -134,6 +148,8 @@ class DocTestRunner:
original_optionflags: int
tries: int
failures: int
if sys.version_info >= (3, 13):
skips: int
test: DocTest
def __init__(self, checker: OutputChecker | None = None, verbose: bool | None = None, optionflags: int = 0) -> None: ...
def report_start(self, out: _Out, test: DocTest, example: Example) -> None: ...