diff options
author | Raymond Hettinger <python@rcn.com> | 2013-03-22 14:26:18 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2013-03-22 14:26:18 (GMT) |
commit | 8f35c891e78c6deafcdc77650bce7e8480e83195 (patch) | |
tree | 367638caf8223dbdf1c55be98fd5d0565b2e3a88 /Doc | |
parent | 1621d77fc8fb2385d26c7de39f55df60426ec6ec (diff) | |
download | cpython-8f35c891e78c6deafcdc77650bce7e8480e83195.zip cpython-8f35c891e78c6deafcdc77650bce7e8480e83195.tar.gz cpython-8f35c891e78c6deafcdc77650bce7e8480e83195.tar.bz2 |
Modernize unittest example
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/tutorial/stdlib.rst | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Doc/tutorial/stdlib.rst b/Doc/tutorial/stdlib.rst index 1ebf792..7e7a154 100644 --- a/Doc/tutorial/stdlib.rst +++ b/Doc/tutorial/stdlib.rst @@ -281,8 +281,10 @@ file:: 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 |