Add durations to unittest in 3.12 (#10636)

This commit is contained in:
Nikita Sobolev
2023-08-30 11:35:25 +01:00
committed by GitHub
parent 8888ac0d6d
commit c9583d9f14
4 changed files with 94 additions and 37 deletions
+7
View File
@@ -1,9 +1,12 @@
import sys
import unittest.case
from _typeshed import OptExcInfo
from collections.abc import Callable
from typing import Any, TextIO, TypeVar
from typing_extensions import TypeAlias
_F = TypeVar("_F", bound=Callable[..., Any])
_DurationsType: TypeAlias = list[tuple[str, float]]
STDOUT_LINE: str
STDERR_LINE: str
@@ -22,6 +25,8 @@ class TestResult:
buffer: bool
failfast: bool
tb_locals: bool
if sys.version_info >= (3, 12):
collectedDurations: _DurationsType
def __init__(self, stream: TextIO | None = None, descriptions: bool | None = None, verbosity: int | None = None) -> None: ...
def printErrors(self) -> None: ...
def wasSuccessful(self) -> bool: ...
@@ -37,3 +42,5 @@ class TestResult:
def addExpectedFailure(self, test: unittest.case.TestCase, err: OptExcInfo) -> None: ...
def addUnexpectedSuccess(self, test: unittest.case.TestCase) -> None: ...
def addSubTest(self, test: unittest.case.TestCase, subtest: unittest.case.TestCase, err: OptExcInfo | None) -> None: ...
if sys.version_info >= (3, 12):
def addDuration(self, test: unittest.case.TestCase, elapsed: float) -> None: ...