Message130598
The current example[0] uses assertTrue(element in self.seq) but it would be better to use assertIn instead. The whole example could be changed to something simpler that uses only the assertTrue/assertEqual/assertRaises methods correctly, e.g.:
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
if __name__ == '__main__':
unittest.main()
[0]: http://docs.python.org/py3k/library/unittest.html#basic-example |
|
Date |
User |
Action |
Args |
2011-03-11 18:15:42 | ezio.melotti | set | recipients:
+ ezio.melotti, rhettinger, ncoghlan, eric.araujo, michael.foord, docs@python |
2011-03-11 18:15:42 | ezio.melotti | set | messageid: <1299867342.41.0.388080450116.issue11468@psf.upfronthosting.co.za> |
2011-03-11 18:15:41 | ezio.melotti | link | issue11468 messages |
2011-03-11 18:15:41 | ezio.melotti | create | |
|