Skip to content

Commit 4dd117f

Browse files
committed
Accept AnyStr in unittest.assertRegex
And also in assertNotRegex, assertRegexpMatches. Closes python#2312.
1 parent f582b53 commit 4dd117f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

stdlib/3/unittest/__init__.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Stubs for unittest
22

33
from typing import (
4-
Any, Callable, Container, ContextManager, Dict, FrozenSet, Generic, Iterable,
4+
Any, AnyStr, Callable, Container, ContextManager, Dict, FrozenSet, Generic, Iterable,
55
Iterator, List, NoReturn, Optional, overload, Pattern, Sequence, Set, TextIO,
66
Tuple, Type, TypeVar, Union
77
)
@@ -111,9 +111,9 @@ class TestCase:
111111
def assertNotAlmostEqual(self, first: float, second: float,
112112
places: int = ..., msg: Any = ...,
113113
delta: float = ...) -> None: ...
114-
def assertRegex(self, text: str, regex: Union[str, Pattern[str]],
114+
def assertRegex(self, text: AnyStr, regex: Union[AnyStr, Pattern[AnyStr]],
115115
msg: Any = ...) -> None: ...
116-
def assertNotRegex(self, text: str, regex: Union[str, Pattern[str]],
116+
def assertNotRegex(self, text: AnyStr, regex: Union[AnyStr, Pattern[AnyStr]],
117117
msg: Any = ...) -> None: ...
118118
def assertCountEqual(self, first: Iterable[Any], second: Iterable[Any],
119119
msg: Any = ...) -> None: ...
@@ -168,7 +168,7 @@ class TestCase:
168168
def assertNotAlmostEquals(self, first: float, second: float,
169169
places: int = ..., msg: Any = ...,
170170
delta: float = ...) -> None: ...
171-
def assertRegexpMatches(self, text: str, regex: Union[str, Pattern[str]],
171+
def assertRegexpMatches(self, text: AnyStr, regex: Union[AnyStr, Pattern[AnyStr]],
172172
msg: Any = ...) -> None: ...
173173
@overload
174174
def assertRaisesRegexp(self, # type: ignore

0 commit comments

Comments
 (0)