diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-30 15:05:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-30 15:05:08 (GMT) |
commit | f15c4d374a07c576c0e8349b16604f6dbad0b953 (patch) | |
tree | 21bb1b432ad3485296391e4c7ef13e8b0fabca86 /Lib/test/test_exceptions.py | |
parent | 16f852345bcdec1bbb15e5363fad6b33bf960912 (diff) | |
download | cpython-f15c4d374a07c576c0e8349b16604f6dbad0b953.zip cpython-f15c4d374a07c576c0e8349b16604f6dbad0b953.tar.gz cpython-f15c4d374a07c576c0e8349b16604f6dbad0b953.tar.bz2 |
bpo-20548: Use specific asserts in warnings and exceptions tests (#788)
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r-- | Lib/test/test_exceptions.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 14e0f84..2cac6c5 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -537,7 +537,7 @@ class ExceptionTests(unittest.TestCase): pass obj = None obj = wr() - self.assertTrue(obj is None, "%s" % obj) + self.assertIsNone(obj) # Qualified "except" without "as" obj = MyObj() @@ -548,7 +548,7 @@ class ExceptionTests(unittest.TestCase): pass obj = None obj = wr() - self.assertTrue(obj is None, "%s" % obj) + self.assertIsNone(obj) # Bare "except" obj = MyObj() @@ -559,7 +559,7 @@ class ExceptionTests(unittest.TestCase): pass obj = None obj = wr() - self.assertTrue(obj is None, "%s" % obj) + self.assertIsNone(obj) # "except" with premature block leave obj = MyObj() @@ -571,7 +571,7 @@ class ExceptionTests(unittest.TestCase): break obj = None obj = wr() - self.assertTrue(obj is None, "%s" % obj) + self.assertIsNone(obj) # "except" block raising another exception obj = MyObj() @@ -592,7 +592,7 @@ class ExceptionTests(unittest.TestCase): # guarantee no ref cycles on CPython (don't gc_collect) if check_impl_detail(cpython=False): gc_collect() - self.assertTrue(obj is None, "%s" % obj) + self.assertIsNone(obj) # Some complicated construct obj = MyObj() @@ -611,7 +611,7 @@ class ExceptionTests(unittest.TestCase): if check_impl_detail(cpython=False): gc_collect() obj = wr() - self.assertTrue(obj is None, "%s" % obj) + self.assertIsNone(obj) # Inside an exception-silencing "with" block class Context: @@ -627,7 +627,7 @@ class ExceptionTests(unittest.TestCase): if check_impl_detail(cpython=False): gc_collect() obj = wr() - self.assertTrue(obj is None, "%s" % obj) + self.assertIsNone(obj) def test_exception_target_in_nested_scope(self): # issue 4617: This used to raise a SyntaxError @@ -779,7 +779,7 @@ class ExceptionTests(unittest.TestCase): testfunc(g) g = obj = None obj = wr() - self.assertIs(obj, None) + self.assertIsNone(obj) def test_generator_throw_cleanup_exc_state(self): def do_throw(g): @@ -904,7 +904,7 @@ class ExceptionTests(unittest.TestCase): except RecursionError: return sys.exc_info() e, v, tb = g() - self.assertTrue(isinstance(v, RecursionError), type(v)) + self.assertIsInstance(v, RecursionError, type(v)) self.assertIn("maximum recursion depth exceeded", str(v)) |