aboutsummaryrefslogtreecommitdiff
path: root/absl/testing
diff options
context:
space:
mode:
authorRebecca Chen <rechen@google.com>2022-03-04 12:20:09 -0800
committerCopybara-Service <copybara-worker@google.com>2022-03-04 12:20:38 -0800
commit778c0b9a75c2b114266769bd0926846049bf8449 (patch)
treede99920704b2f68f7780747ebafbbc5d78231d2a /absl/testing
parent7945da4917ff12828304acd562887f1abd545f3b (diff)
downloadabsl-py-778c0b9a75c2b114266769bd0926846049bf8449.tar.gz
Improve the type annotations for assertRaisesWith{Literal,Predicate}Match.
PiperOrigin-RevId: 432505574 Change-Id: I581809fc35b40fd477a111154065a281c53eee00
Diffstat (limited to 'absl/testing')
-rw-r--r--absl/testing/absltest.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/absl/testing/absltest.py b/absl/testing/absltest.py
index 1ade38e..37b902e 100644
--- a/absl/testing/absltest.py
+++ b/absl/testing/absltest.py
@@ -1364,6 +1364,21 @@ class TestCase(unittest.TestCase):
self.test_func(exc_value)
return True
+ @typing.overload
+ def assertRaisesWithPredicateMatch(
+ self, expected_exception, predicate) -> _AssertRaisesContext:
+ # The purpose of this return statement is to work around
+ # https://github.com/PyCQA/pylint/issues/5273; it is otherwise ignored.
+ return self._AssertRaisesContext(None, None, None)
+
+ @typing.overload
+ def assertRaisesWithPredicateMatch(
+ self, expected_exception, predicate, callable_obj: Callable[..., Any],
+ *args, **kwargs) -> None:
+ # The purpose of this return statement is to work around
+ # https://github.com/PyCQA/pylint/issues/5273; it is otherwise ignored.
+ return self._AssertRaisesContext(None, None, None)
+
def assertRaisesWithPredicateMatch(self, expected_exception, predicate,
callable_obj=None, *args, **kwargs):
"""Asserts that exception is thrown and predicate(exception) is true.
@@ -1392,6 +1407,22 @@ class TestCase(unittest.TestCase):
with context:
callable_obj(*args, **kwargs)
+ @typing.overload
+ def assertRaisesWithLiteralMatch(
+ self, expected_exception, expected_exception_message
+ ) -> _AssertRaisesContext:
+ # The purpose of this return statement is to work around
+ # https://github.com/PyCQA/pylint/issues/5273; it is otherwise ignored.
+ return self._AssertRaisesContext(None, None, None)
+
+ @typing.overload
+ def assertRaisesWithLiteralMatch(
+ self, expected_exception, expected_exception_message,
+ callable_obj: Callable[..., Any], *args, **kwargs) -> None:
+ # The purpose of this return statement is to work around
+ # https://github.com/PyCQA/pylint/issues/5273; it is otherwise ignored.
+ return self._AssertRaisesContext(None, None, None)
+
def assertRaisesWithLiteralMatch(self, expected_exception,
expected_exception_message,
callable_obj=None, *args, **kwargs):