3
import diamond.plist as plist
6
class PyListModule(unittest.TestCase):
8
''' #1: A simple list of integers, with cardinality ''. (One element only). '''
11
self.assertEqual(l.__str__(), "list of <type 'int'> of cardinality: ")
12
self.assertEqual(l.__repr__(), "list of <type 'int'> of cardinality: ")
13
self.assertEqual(l("0"), "0")
15
''' #2: A simple list of integers, with cardinality '+'. '''
16
def testOneOrMore(self):
17
l = plist.List(int, '+')
18
self.assertEqual(l.__str__(), "list of <type 'int'> of cardinality: +")
19
self.assertEqual(l.__repr__(), "list of <type 'int'> of cardinality: +")
20
self.assertEqual(l("3,4,5"), "3 4 5")
22
''' #3: A list of two strings, with cardinality 2. '''
23
def testTwoStrings(self):
24
l = plist.List(str, "2")
25
self.assertEqual(l.__str__(), "list of <type 'str'> of cardinality: 2")
26
self.assertEqual(l.__repr__(), "list of <type 'str'> of cardinality: 2")
27
self.assertEqual(l("first second"), "first second")
29
''' #4: A list of none type, which should throw an non-callable exception when called. '''
30
def testNoneType(self):
38
if __name__ == '__main__':
39
suite = unittest.TestLoader().loadTestsFromTestCase(PyListModule)
40
unittest.TextTestRunner(verbosity=3).run(suite)