summaryrefslogtreecommitdiffstats
path: root/Doc/library/unittest.rst
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-02-04 20:29:01 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-02-04 20:29:01 (GMT)
commitd503180449004a857e7023dd0ba3e9730b50575e (patch)
tree0a4326e48461f72366334a3c510a8d54a9a73fe8 /Doc/library/unittest.rst
parentc9213f5849d50bd5eadd8ba3622644881b47403a (diff)
downloadcpython-d503180449004a857e7023dd0ba3e9730b50575e.zip
cpython-d503180449004a857e7023dd0ba3e9730b50575e.tar.gz
cpython-d503180449004a857e7023dd0ba3e9730b50575e.tar.bz2
Merged revisions 77976 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r77976 | ezio.melotti | 2010-02-04 22:27:41 +0200 (Thu, 04 Feb 2010) | 9 lines Merged revisions 77968 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r77968 | ezio.melotti | 2010-02-04 22:06:38 +0200 (Thu, 04 Feb 2010) | 1 line Use correct assert* methods in the examples. ........ ................
Diffstat (limited to 'Doc/library/unittest.rst')
-rw-r--r--Doc/library/unittest.rst20
1 files changed, 10 insertions, 10 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index d1a71e3..051c730 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -115,12 +115,12 @@ Here is a short script to test three functions from the :mod:`random` module::
def test_choice(self):
element = random.choice(self.seq)
- self.assert_(element in self.seq)
+ self.assertIn(element, self.seq)
def test_sample(self):
self.assertRaises(ValueError, random.sample, self.seq, 20)
for element in random.sample(self.seq, 5):
- self.assert_(element in self.seq)
+ self.assertIn(element, self.seq)
if __name__ == '__main__':
unittest.main()
@@ -236,14 +236,14 @@ us when we run the test::
class DefaultWidgetSizeTestCase(SimpleWidgetTestCase):
def runTest(self):
- self.assertTrue(self.widget.size() == (50,50),
- 'incorrect default size')
+ self.assertEqual(self.widget.size(), (50,50),
+ 'incorrect default size')
class WidgetResizeTestCase(SimpleWidgetTestCase):
def runTest(self):
self.widget.resize(100,150)
- self.assertTrue(self.widget.size() == (100,150),
- 'wrong size after resize')
+ self.assertEqual(self.widget.size(), (100,150),
+ 'wrong size after resize')
If the :meth:`~TestCase.setUp` method raises an exception while the test is
running, the framework will consider the test to have suffered an error, and the
@@ -284,13 +284,13 @@ mechanism::
self.widget = None
def testDefaultSize(self):
- self.assertTrue(self.widget.size() == (50,50),
- 'incorrect default size')
+ self.assertEqual(self.widget.size(), (50,50),
+ 'incorrect default size')
def testResize(self):
self.widget.resize(100,150)
- self.assertTrue(self.widget.size() == (100,150),
- 'wrong size after resize')
+ self.assertEqual(self.widget.size(), (100,150),
+ 'wrong size after resize')
Here we have not provided a :meth:`~TestCase.runTest` method, but have instead
provided two different test methods. Class instances will now each run one of