From 99a6fb31087eb42d1711171d86f059ed3c37645a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Mon, 4 Nov 2019 16:10:45 +0000 Subject: [PATCH] Add the (deprecated) assertDictContainsSubset() to TestCase. (#3437) Until this is removed from the standard library, it probably should stay in the typing. Also update both 2 and 3 definitions to use Mapping[Any, Any], rather than Dict[Any, Any]. --- stdlib/2/unittest.pyi | 9 ++++++--- stdlib/3/unittest/case.pyi | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/stdlib/2/unittest.pyi b/stdlib/2/unittest.pyi index 948e141a4..366a37352 100644 --- a/stdlib/2/unittest.pyi +++ b/stdlib/2/unittest.pyi @@ -3,8 +3,8 @@ # Based on http://docs.python.org/2.7/library/unittest.html from typing import (Any, Callable, Dict, FrozenSet, Iterable, Iterator, - List, NoReturn, Optional, overload, Pattern, Sequence, Set, - Text, TextIO, Tuple, Type, TypeVar, Union) + List, Mapping, NoReturn, Optional, overload, Pattern, + Sequence, Set, Text, TextIO, Tuple, Type, TypeVar, Union) from abc import abstractmethod, ABCMeta import datetime import types @@ -166,7 +166,10 @@ class TestCase(Testable): def assertRegexpMatches(self, text: Text, regexp: _Regexp, msg: object = ...) -> None: ... def assertNotRegexpMatches(self, text: Text, regexp: _Regexp, msg: object = ...) -> None: ... def assertItemsEqual(self, first: Iterable[Any], second: Iterable[Any], msg: object = ...) -> None: ... - def assertDictContainsSubset(self, expected: Dict[Any, Any], actual: Dict[Any, Any], msg: object = ...) -> None: ... + def assertDictContainsSubset(self, + expected: Mapping[Any, Any], + actual: Mapping[Any, Any], + msg: object = ...) -> None: ... def addTypeEqualityFunc(self, typeobj: type, function: Callable[..., None]) -> None: ... @overload def failUnlessRaises(self, exception: _ExceptionType, callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... diff --git a/stdlib/3/unittest/case.pyi b/stdlib/3/unittest/case.pyi index 9a074cb84..dbbf1048f 100644 --- a/stdlib/3/unittest/case.pyi +++ b/stdlib/3/unittest/case.pyi @@ -5,8 +5,8 @@ import unittest.result from types import TracebackType from typing import ( Any, AnyStr, Callable, Container, ContextManager, Dict, FrozenSet, Generic, - Iterable, List, NoReturn, Optional, overload, Pattern, Sequence, Set, - Tuple, Type, TypeVar, Union, + Iterable, List, Mapping, NoReturn, Optional, overload, Pattern, Sequence, + Set, Tuple, Type, TypeVar, Union, ) _E = TypeVar('_E', bound=BaseException) @@ -215,6 +215,10 @@ class TestCase: exception: Union[Type[_E], Tuple[Type[_E], ...]], expected_regex: Union[str, bytes, Pattern[str], Pattern[bytes]], msg: Any = ...) -> _AssertRaisesContext[_E]: ... + def assertDictContainsSubset(self, + expected: Mapping[Any, Any], + actual: Mapping[Any, Any], + msg: object = ...) -> None: ... class FunctionTestCase(TestCase): def __init__(self, testFunc: Callable[[], None],