summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-02-04 20:27:41 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-02-04 20:27:41 (GMT)
commit2d6c39b24fee77b32ce3bebd1ca01291ba47d15d (patch)
tree415b0169fccd5e4bd8710e4121094bbd730fa01e
parentb6375f12664f32f9c997609adab6e73c58721c69 (diff)
downloadcpython-2d6c39b24fee77b32ce3bebd1ca01291ba47d15d.zip
cpython-2d6c39b24fee77b32ce3bebd1ca01291ba47d15d.tar.gz
cpython-2d6c39b24fee77b32ce3bebd1ca01291ba47d15d.tar.bz2
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. ........
-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 bd88310..6023c24 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -182,12 +182,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()
@@ -301,14 +301,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
@@ -349,13 +349,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