mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Add undocumented methods and make types more specific in 2/unittest (#3550)
This commit is contained in:
committed by
Sebastian Rittau
parent
9d61baa7be
commit
a705d59479
@@ -15,6 +15,11 @@ _FT = TypeVar('_FT')
|
||||
_ExceptionType = Union[Type[BaseException], Tuple[Type[BaseException], ...]]
|
||||
_Regexp = Union[Text, Pattern[Text]]
|
||||
|
||||
_SysExcInfoType = Union[
|
||||
Tuple[Type[BaseException], BaseException, types.TracebackType],
|
||||
Tuple[None, None, None],
|
||||
]
|
||||
|
||||
class Testable(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def run(self, result: TestResult) -> None: ...
|
||||
@@ -26,11 +31,11 @@ class Testable(metaclass=ABCMeta):
|
||||
# TODO ABC for test runners?
|
||||
|
||||
class TestResult:
|
||||
errors: List[Tuple[Testable, str]]
|
||||
failures: List[Tuple[Testable, str]]
|
||||
skipped: List[Tuple[Testable, str]]
|
||||
expectedFailures: List[Tuple[Testable, str]]
|
||||
unexpectedSuccesses: List[Testable]
|
||||
errors: List[Tuple[TestCase, str]]
|
||||
failures: List[Tuple[TestCase, str]]
|
||||
skipped: List[Tuple[TestCase, str]]
|
||||
expectedFailures: List[Tuple[TestCase, str]]
|
||||
unexpectedSuccesses: List[TestCase]
|
||||
shouldStop: bool
|
||||
testsRun: int
|
||||
buffer: bool
|
||||
@@ -38,16 +43,16 @@ class TestResult:
|
||||
|
||||
def wasSuccessful(self) -> bool: ...
|
||||
def stop(self) -> None: ...
|
||||
def startTest(self, test: Testable) -> None: ...
|
||||
def stopTest(self, test: Testable) -> None: ...
|
||||
def startTest(self, test: TestCase) -> None: ...
|
||||
def stopTest(self, test: TestCase) -> None: ...
|
||||
def startTestRun(self) -> None: ...
|
||||
def stopTestRun(self) -> None: ...
|
||||
def addError(self, test: Testable, err: Tuple[type, Any, Any]) -> None: ... # TODO
|
||||
def addFailure(self, test: Testable, err: Tuple[type, Any, Any]) -> None: ... # TODO
|
||||
def addSuccess(self, test: Testable) -> None: ...
|
||||
def addSkip(self, test: Testable, reason: str) -> None: ...
|
||||
def addExpectedFailure(self, test: Testable, err: str) -> None: ...
|
||||
def addUnexpectedSuccess(self, test: Testable) -> None: ...
|
||||
def addError(self, test: TestCase, err: _SysExcInfoType) -> None: ...
|
||||
def addFailure(self, test: TestCase, err: _SysExcInfoType) -> None: ...
|
||||
def addSuccess(self, test: TestCase) -> None: ...
|
||||
def addSkip(self, test: TestCase, reason: str) -> None: ...
|
||||
def addExpectedFailure(self, test: TestCase, err: str) -> None: ...
|
||||
def addUnexpectedSuccess(self, test: TestCase) -> None: ...
|
||||
|
||||
class _AssertRaisesBaseContext:
|
||||
expected: Any
|
||||
@@ -240,12 +245,16 @@ defaultTestLoader: TestLoader
|
||||
|
||||
class TextTestResult(TestResult):
|
||||
def __init__(self, stream: TextIO, descriptions: bool, verbosity: int) -> None: ...
|
||||
def getDescription(self, test: TestCase) -> str: ... # undocumented
|
||||
def printErrors(self) -> None: ... # undocumented
|
||||
def printErrorList(self, flavour: str, errors: List[Tuple[TestCase, str]]) -> None: ... # undocumented
|
||||
|
||||
class TextTestRunner:
|
||||
def __init__(self, stream: Optional[TextIO] = ..., descriptions: bool = ...,
|
||||
verbosity: int = ..., failfast: bool = ..., buffer: bool = ...,
|
||||
resultclass: Optional[Type[TestResult]] = ...) -> None: ...
|
||||
def _makeResult(self) -> TestResult: ...
|
||||
def run(self, test: Testable) -> TestResult: ... # undocumented
|
||||
|
||||
class SkipTest(Exception):
|
||||
...
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from typing import List, Optional, Tuple, Type
|
||||
from typing import List, Optional, Tuple, Type, Union
|
||||
from types import TracebackType
|
||||
import unittest.case
|
||||
|
||||
|
||||
_SysExcInfoType = Tuple[Optional[Type[BaseException]],
|
||||
Optional[BaseException],
|
||||
Optional[TracebackType]]
|
||||
_SysExcInfoType = Union[
|
||||
Tuple[Type[BaseException], BaseException, TracebackType],
|
||||
Tuple[None, None, None],
|
||||
]
|
||||
|
||||
|
||||
class TestResult:
|
||||
|
||||
Reference in New Issue
Block a user