Mercurial > cpython-lru_cache-weakref
diff Doc/tutorial/stdlib.rst @ 82877:d6336b2e4db6 2.7
Modernize unittest example
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 22 Mar 2013 07:17:38 -0700 |
| parents | 063a052af878 |
| children |
line wrap: on
line diff
--- a/Doc/tutorial/stdlib.rst Thu Mar 21 15:02:16 2013 -0700 +++ b/Doc/tutorial/stdlib.rst Fri Mar 22 07:17:38 2013 -0700 @@ -278,8 +278,10 @@ def test_average(self): self.assertEqual(average([20, 30, 70]), 40.0) self.assertEqual(round(average([1, 5, 7]), 1), 4.3) - self.assertRaises(ZeroDivisionError, average, []) - self.assertRaises(TypeError, average, 20, 30, 70) + with self.assertRaises(ZeroDivisionError): + average([]) + with self.assertRaises(TypeError): + average(20, 30, 70) unittest.main() # Calling from the command line invokes all tests
