1import unittest
2
3class TestStringMethods(unittest.TestCase):
4
5 def test_upper(self):
6 self.assertEqual('foo'.upper(), 'FOO')
7
8 def test_isupper(self):
9 self.assertTrue('FOO'.isupper())
10 self.assertFalse('Foo'.isupper())
11
12 def test_split(self):
13 s = 'hello world'
14 self.assertEqual(s.split(), ['hello', 'world'])
15 # check that s.split fails when the separator is not a string
16 with self.assertRaises(TypeError):
17 s.split(2)
18
19if __name__ == '__main__':
20 unittest.main()
21