File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
tensorflow_datasets/testing Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,6 @@ def setUp(self):
59
59
# get_temp_dir is actually the same for all tests, so create a temp sub-dir.
60
60
self .tmp_dir = tempfile .mkdtemp (dir = tf .compat .v1 .test .get_temp_dir ())
61
61
62
- def assertRaisesWithPredicateMatch (self , err_type , predicate ):
63
- if isinstance (predicate , str ):
64
- predicate_fct = lambda err : predicate in str (err )
65
- else :
66
- predicate_fct = predicate
67
- return super ().assertRaisesWithPredicateMatch (err_type , predicate_fct )
68
-
69
62
@contextlib .contextmanager
70
63
def assertLogs (self , text , level = "info" ):
71
64
with mock .patch .object (logging , level ) as mock_log :
Original file line number Diff line number Diff line change 18
18
from collections .abc import Sequence
19
19
import contextlib
20
20
from typing import Any , ContextManager
21
- import unittest
22
21
22
+ from absl .testing import absltest
23
23
24
- class TestCaseInContext (unittest .TestCase ):
24
+
25
+ class TestCaseInContext (absltest .TestCase ):
25
26
"""Base TestCase for running tests inside the given contexts.
26
27
27
28
It ensures that all contexts are entered before any test starts and are exited
@@ -47,3 +48,10 @@ def tearDownClass(cls):
47
48
# Exit all contexts in the reverse order
48
49
cls ._stack .close ()
49
50
super ().tearDownClass ()
51
+
52
+ def assertRaisesWithPredicateMatch (self , err_type , predicate ): # pylint: disable=invalid-name
53
+ if isinstance (predicate , str ):
54
+ predicate_fn = lambda err : predicate in str (err )
55
+ else :
56
+ predicate_fn = predicate
57
+ return super ().assertRaisesWithPredicateMatch (err_type , predicate_fn )
You can’t perform that action at this time.
0 commit comments