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.
........
This commit is contained in:
Ezio Melotti 2010-02-04 20:22:44 +00:00
parent 2d95c3a7d8
commit f85bba5431
1 changed files with 10 additions and 10 deletions

View File

@ -114,12 +114,12 @@ Here is a short script to test three functions from the :mod:`random` module::
def testchoice(self):
element = random.choice(self.seq)
self.assert_(element in self.seq)
self.assertTrue(element in self.seq)
def testsample(self):
self.assertRaises(ValueError, random.sample, self.seq, 20)
for element in random.sample(self.seq, 5):
self.assert_(element in self.seq)
self.assertTrue(element in self.seq)
if __name__ == '__main__':
unittest.main()
@ -234,14 +234,14 @@ we run the test::
class DefaultWidgetSizeTestCase(SimpleWidgetTestCase):
def runTest(self):
self.failUnless(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.failUnless(self.widget.size() == (100,150),
'wrong size after resize')
self.assertEqual(self.widget.size(), (100,150),
'wrong size after resize')
If the :meth:`setUp` method raises an exception while the test is running, the
framework will consider the test to have suffered an error, and the
@ -282,13 +282,13 @@ mechanism::
self.widget = None
def testDefaultSize(self):
self.failUnless(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.failUnless(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:`runTest` method, but have instead provided
two different test methods. Class instances will now each run one of the