Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_contextlib.py @ 86403:22247b7d17fa
Close #19266: contextlib.ignore -> contextlib.suppress
Patch by Zero Piraeus.
| author | Nick Coghlan <ncoghlan@gmail.com> |
|---|---|
| date | Thu, 17 Oct 2013 23:40:57 +1000 |
| parents | f014b5f0773f |
| children | 124a7ba1e911 |
line wrap: on
line diff
--- a/Lib/test/test_contextlib.py Thu Oct 17 14:31:51 2013 +0100 +++ b/Lib/test/test_contextlib.py Thu Oct 17 23:40:57 2013 +1000 @@ -632,28 +632,6 @@ stack.push(cm) self.assertIs(stack._exit_callbacks[-1], cm) -class TestIgnore(unittest.TestCase): - - def test_no_exception(self): - - with ignore(ValueError): - self.assertEqual(pow(2, 5), 32) - - def test_exact_exception(self): - - with ignore(TypeError): - len(5) - - def test_multiple_exception_args(self): - - with ignore(ZeroDivisionError, TypeError): - len(5) - - def test_exception_hierarchy(self): - - with ignore(LookupError): - 'Hello'[50] - class TestRedirectStdout(unittest.TestCase): def test_redirect_to_string_io(self): @@ -663,5 +641,27 @@ s = f.getvalue() self.assertIn('pow', s) +class TestSuppress(unittest.TestCase): + + def test_no_exception(self): + + with suppress(ValueError): + self.assertEqual(pow(2, 5), 32) + + def test_exact_exception(self): + + with suppress(TypeError): + len(5) + + def test_multiple_exception_args(self): + + with suppress(ZeroDivisionError, TypeError): + len(5) + + def test_exception_hierarchy(self): + + with suppress(LookupError): + 'Hello'[50] + if __name__ == "__main__": unittest.main()
