Skip to content

Fixes to unittest stubs #1024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions stdlib/3/unittest/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import (
Any, Callable, Dict, Iterable, Iterator, List, Optional, Pattern, Sequence,
Set, TextIO, Tuple, Type, TypeVar, Union,
Set, TextIO, Tuple, Type, TypeVar, Union, Generic,
overload,
)
import logging
Expand All @@ -13,6 +13,7 @@ from contextlib import ContextManager

_T = TypeVar('_T')
_FT = TypeVar('_FT', Callable[[Any], Any])
_E = TypeVar('_E', bound=Exception)


def skip(reason: str) -> Callable[[_FT], _FT]: ...
Expand Down Expand Up @@ -70,25 +71,25 @@ class TestCase:
@overload
def assertRaises(self, # type: ignore
exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]],
callable: Callable[..., Any] = ...,
callable: Callable[..., Any],
*args: Any, **kwargs: Any) -> None: ...
@overload
def assertRaises(self,
exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]],
msg: Any = ...) -> _AssertRaisesContext: ...
exception: Union[Type[_E], Tuple[Type[_E], ...]],
msg: Any = ...) -> _AssertRaisesContext[_E]: ...
@overload
def assertRaisesRegex(self, # type: ignore
exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]],
callable: Callable[..., Any] = ...,
callable: Callable[..., Any],
*args: Any, **kwargs: Any) -> None: ...
@overload
def assertRaisesRegex(self,
exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]],
msg: Any = ...) -> _AssertRaisesContext: ...
exception: Union[Type[_E], Tuple[Type[_E], ...]],
msg: Any = ...) -> _AssertRaisesContext[_E]: ...
@overload
def assertWarns(self, # type: ignore
exception: Union[Type[Warning], Tuple[Type[Warning], ...]],
callable: Callable[..., Any] = ...,
callable: Callable[..., Any],
*args: Any, **kwargs: Any) -> None: ...
@overload
def assertWarns(self,
Expand All @@ -97,7 +98,7 @@ class TestCase:
@overload
def assertWarnsRegex(self, # type: ignore
exception: Union[Type[Warning], Tuple[Type[Warning], ...]],
callable: Callable[..., Any] = ...,
callable: Callable[..., Any],
*args: Any, **kwargs: Any) -> None: ...
@overload
def assertWarnsRegex(self,
Expand Down Expand Up @@ -159,8 +160,8 @@ class TestCase:
*args: Any, **kwargs: Any) -> None: ...
@overload
def failUnlessRaises(self,
exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]],
msg: Any = ...) -> _AssertRaisesContext: ...
exception: Union[Type[_E], Tuple[Type[_E], ...]],
msg: Any = ...) -> _AssertRaisesContext[_E]: ...
def failUnlessAlmostEqual(self, first: float, second: float,
places: int = ..., msg: Any = ...) -> None: ...
def assertAlmostEquals(self, first: float, second: float, places: int = ...,
Expand All @@ -179,18 +180,18 @@ class TestCase:
*args: Any, **kwargs: Any) -> None: ...
@overload
def assertRaisesRegexp(self,
exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]],
msg: Any = ...) -> _AssertRaisesContext: ...
exception: Union[Type[_E], Tuple[Type[_E], ...]],
msg: Any = ...) -> _AssertRaisesContext[_E]: ...

class FunctionTestCase(TestCase):
def __init__(self, testFunc: Callable[[], None],
setUp: Optional[Callable[[], None]] = ...,
tearDown: Optional[Callable[[], None]] = ...,
description: Optional[str] = ...) -> None: ...

class _AssertRaisesContext:
exception = ... # type: Exception
def __enter__(self) -> _AssertRaisesContext: ...
class _AssertRaisesContext(Generic[_E]):
exception = ... # type: _E
def __enter__(self) -> _AssertRaisesContext[_E]: ...
def __exit__(self, exc_type: Optional[type], exc_val: Optional[Exception],
exc_tb: Optional[TracebackType]) -> bool: ...

Expand Down