[Python-checkins] cpython (3.3): Modernize unittest example
raymond.hettinger
python-checkins at python.org
Fri Mar 22 15:27:31 CET 2013
http://hg.python.org/cpython/rev/5540ed8c9824
changeset: 82878:5540ed8c9824
branch: 3.3
parent: 82870:14f0c9e595a5
user: Raymond Hettinger <python at rcn.com>
date: Fri Mar 22 07:26:18 2013 -0700
summary:
Modernize unittest example
files:
Doc/tutorial/stdlib.rst | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Doc/tutorial/stdlib.rst b/Doc/tutorial/stdlib.rst
--- a/Doc/tutorial/stdlib.rst
+++ b/Doc/tutorial/stdlib.rst
@@ -281,8 +281,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
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list