diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2013-10-17 13:40:57 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2013-10-17 13:40:57 (GMT) |
commit | 240f86d7ddbeb3800d39a6d2e6e7a7d1f0c49799 (patch) | |
tree | ec61711162ebf82864716dee27119461c312ba58 /Lib/test/test_contextlib.py | |
parent | 1eb509a585c402faa76da85095f1bdae5cd54ef2 (diff) | |
download | cpython-240f86d7ddbeb3800d39a6d2e6e7a7d1f0c49799.zip cpython-240f86d7ddbeb3800d39a6d2e6e7a7d1f0c49799.tar.gz cpython-240f86d7ddbeb3800d39a6d2e6e7a7d1f0c49799.tar.bz2 |
Close #19266: contextlib.ignore -> contextlib.suppress
Patch by Zero Piraeus.
Diffstat (limited to 'Lib/test/test_contextlib.py')
-rw-r--r-- | Lib/test/test_contextlib.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py index 48f8fa9..5c1c5c5 100644 --- a/Lib/test/test_contextlib.py +++ b/Lib/test/test_contextlib.py @@ -632,36 +632,36 @@ class TestExitStack(unittest.TestCase): stack.push(cm) self.assertIs(stack._exit_callbacks[-1], cm) -class TestIgnore(unittest.TestCase): +class TestRedirectStdout(unittest.TestCase): + + def test_redirect_to_string_io(self): + f = io.StringIO() + with redirect_stdout(f): + help(pow) + s = f.getvalue() + self.assertIn('pow', s) + +class TestSuppress(unittest.TestCase): def test_no_exception(self): - with ignore(ValueError): + with suppress(ValueError): self.assertEqual(pow(2, 5), 32) def test_exact_exception(self): - with ignore(TypeError): + with suppress(TypeError): len(5) def test_multiple_exception_args(self): - with ignore(ZeroDivisionError, TypeError): + with suppress(ZeroDivisionError, TypeError): len(5) def test_exception_hierarchy(self): - with ignore(LookupError): + with suppress(LookupError): 'Hello'[50] -class TestRedirectStdout(unittest.TestCase): - - def test_redirect_to_string_io(self): - f = io.StringIO() - with redirect_stdout(f): - help(pow) - s = f.getvalue() - self.assertIn('pow', s) - if __name__ == "__main__": unittest.main() |