-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
20 lines (16 loc) · 723 Bytes
/
tests.py
File metadata and controls
20 lines (16 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import unittest
class TestStringMethod_Upper(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO', "'foo'.upper()=='FOO'")
def test_isupper(self):
self.assertTrue('FOO'.isupper(),"isupper +positive case")
self.assertFalse('Foo'.isupper(), "isupper -negative case")
class TestStringMethod_Split(unittest.TestCase):
def test_twoWords(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'], "split on a space")
def test_splitInt(self):
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError, "invalid separator"):
s = 'hello world'
s.split(2)