diff options
author | Raymond Hettinger <python@rcn.com> | 2013-03-22 14:17:38 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2013-03-22 14:17:38 (GMT) |
commit | 45072741393412f0336d8356f9f597d7c2e1abed (patch) | |
tree | 63797c38ab743dbe6a7f9f74624cc0cade2bf50b /Doc/tutorial | |
parent | 28b7c05131765ebdf2efa106c861b7b08008f1fc (diff) | |
download | cpython-45072741393412f0336d8356f9f597d7c2e1abed.zip cpython-45072741393412f0336d8356f9f597d7c2e1abed.tar.gz cpython-45072741393412f0336d8356f9f597d7c2e1abed.tar.bz2 |
Modernize unittest example
Diffstat (limited to 'Doc/tutorial')
-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 1343649..f6239d6 100644 --- a/Doc/tutorial/stdlib.rst +++ b/Doc/tutorial/stdlib.rst @@ -278,8 +278,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 |