diff options
author | Ran Benita <ran@unusedvar.com> | 2020-05-01 14:40:15 +0300 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-06-05 11:34:19 +0300 |
commit | 247c4c0482888b18203589a2d0461d598bd2d817 (patch) | |
tree | 917e1946bc1a161457d159b468a7940b3efd66bb /src/_pytest/unittest.py | |
parent | ef347295418451e1f09bfb9af1a77aba10b3e71c (diff) | |
download | pytest-247c4c0482888b18203589a2d0461d598bd2d817.tar.gz |
Type annotate some more hooks & impls
Diffstat (limited to 'src/_pytest/unittest.py')
-rw-r--r-- | src/_pytest/unittest.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index b2e6ab89d..3fbf7c88d 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -1,6 +1,8 @@ """ discovery and running of std-library "unittest" style tests. """ import sys import traceback +from typing import Any +from typing import Generator from typing import Iterable from typing import Optional from typing import Union @@ -253,7 +255,7 @@ class TestCaseFunction(Function): @hookimpl(tryfirst=True) -def pytest_runtest_makereport(item, call): +def pytest_runtest_makereport(item: Item, call: CallInfo) -> None: if isinstance(item, TestCaseFunction): if item._excinfo: call.excinfo = item._excinfo.pop(0) @@ -263,7 +265,13 @@ def pytest_runtest_makereport(item, call): pass unittest = sys.modules.get("unittest") - if unittest and call.excinfo and call.excinfo.errisinstance(unittest.SkipTest): + if ( + unittest + and call.excinfo + and call.excinfo.errisinstance( + unittest.SkipTest # type: ignore[attr-defined] # noqa: F821 + ) + ): # let's substitute the excinfo with a pytest.skip one call2 = CallInfo.from_call( lambda: pytest.skip(str(call.excinfo.value)), call.when @@ -275,9 +283,9 @@ def pytest_runtest_makereport(item, call): @hookimpl(hookwrapper=True) -def pytest_runtest_protocol(item): +def pytest_runtest_protocol(item: Item) -> Generator[None, None, None]: if isinstance(item, TestCaseFunction) and "twisted.trial.unittest" in sys.modules: - ut = sys.modules["twisted.python.failure"] + ut = sys.modules["twisted.python.failure"] # type: Any Failure__init__ = ut.Failure.__init__ check_testcase_implements_trial_reporter() |