mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
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:
parent
b6375f1266
commit
2d6c39b24f
1 changed files with 10 additions and 10 deletions
|
@ -182,12 +182,12 @@ Here is a short script to test three functions from the :mod:`random` module::
|
||||||
|
|
||||||
def test_choice(self):
|
def test_choice(self):
|
||||||
element = random.choice(self.seq)
|
element = random.choice(self.seq)
|
||||||
self.assert_(element in self.seq)
|
self.assertIn(element, self.seq)
|
||||||
|
|
||||||
def test_sample(self):
|
def test_sample(self):
|
||||||
self.assertRaises(ValueError, random.sample, self.seq, 20)
|
self.assertRaises(ValueError, random.sample, self.seq, 20)
|
||||||
for element in random.sample(self.seq, 5):
|
for element in random.sample(self.seq, 5):
|
||||||
self.assert_(element in self.seq)
|
self.assertIn(element, self.seq)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -301,14 +301,14 @@ us when we run the test::
|
||||||
|
|
||||||
class DefaultWidgetSizeTestCase(SimpleWidgetTestCase):
|
class DefaultWidgetSizeTestCase(SimpleWidgetTestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
self.assertTrue(self.widget.size() == (50,50),
|
self.assertEqual(self.widget.size(), (50,50),
|
||||||
'incorrect default size')
|
'incorrect default size')
|
||||||
|
|
||||||
class WidgetResizeTestCase(SimpleWidgetTestCase):
|
class WidgetResizeTestCase(SimpleWidgetTestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
self.widget.resize(100,150)
|
self.widget.resize(100,150)
|
||||||
self.assertTrue(self.widget.size() == (100,150),
|
self.assertEqual(self.widget.size(), (100,150),
|
||||||
'wrong size after resize')
|
'wrong size after resize')
|
||||||
|
|
||||||
If the :meth:`~TestCase.setUp` method raises an exception while the test is
|
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
|
running, the framework will consider the test to have suffered an error, and the
|
||||||
|
@ -349,13 +349,13 @@ mechanism::
|
||||||
self.widget = None
|
self.widget = None
|
||||||
|
|
||||||
def testDefaultSize(self):
|
def testDefaultSize(self):
|
||||||
self.assertTrue(self.widget.size() == (50,50),
|
self.assertEqual(self.widget.size(), (50,50),
|
||||||
'incorrect default size')
|
'incorrect default size')
|
||||||
|
|
||||||
def testResize(self):
|
def testResize(self):
|
||||||
self.widget.resize(100,150)
|
self.widget.resize(100,150)
|
||||||
self.assertTrue(self.widget.size() == (100,150),
|
self.assertEqual(self.widget.size(), (100,150),
|
||||||
'wrong size after resize')
|
'wrong size after resize')
|
||||||
|
|
||||||
Here we have not provided a :meth:`~TestCase.runTest` method, but have instead
|
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
|
provided two different test methods. Class instances will now each run one of
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue