Improve the unittest stubs. (#1927)

* Improvements to stdlib/2/unittest.pyi

* Adds a bunch of missing things.
* Fixes the signatures of assertRaises and failUnlessRaises.
* Corrects the name of a TestCase subclass from CallableTestCase
  to FunctionTestCase.
* Makes defaultTestLoader an instance of TestLoader, as it should
  be, rather than an alias. Based on https://docs.python.org/2/library/unittest.html and
  https://github.com/python/cpython/tree/2.7/Lib/unittest.

* Improvements to stdlib/3/unittest/__init__.pyi

* The constructor arguments to TextTestResult are all required.
* There is a module-level load_tests() function.
* removeResult() returns a bool. Based on https://docs.python.org/3/library/unittest.html and
  https://github.com/python/cpython/tree/master/Lib/unittest.
This commit is contained in:
rchen152
2018-02-27 06:46:10 -08:00
committed by Matthias Kramm
parent 9b6df1d6bc
commit 066c434410
2 changed files with 63 additions and 17 deletions

View File

@@ -279,8 +279,8 @@ class TestResult:
outcome: Optional[_SysExcInfoType]) -> None: ...
class TextTestResult(TestResult):
def __init__(self, stream: TextIO = ..., descriptions: bool = ...,
verbosity: int = ...) -> None: ...
def __init__(self, stream: TextIO, descriptions: bool,
verbosity: int) -> None: ...
_TextTestResult = TextTestResult
defaultTestLoader = ... # type: TestLoader
@@ -324,10 +324,12 @@ def main(module: str = ..., defaultTest: _DefaultTestType = ...,
buffer: Optional[bool] = ...,
warnings: Optional[str] = ...) -> TestProgram: ...
def load_tests(loader: TestLoader, tests: TestSuite,
pattern: Optional[str]) -> TestSuite: ...
def installHandler() -> None: ...
def registerResult(result: TestResult) -> None: ...
def removeResult(result: TestResult) -> None: ...
def removeResult(result: TestResult) -> bool: ...
@overload
def removeHandler() -> None: ...
@overload