-
Notifications
You must be signed in to change notification settings - Fork 2
/
alg_tests.py
42 lines (32 loc) · 889 Bytes
/
alg_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
#
# Self tests for cs.alg module.
# - Cameron Simpson <cs@cskk.id.au>
#
import sys
import unittest
from cs.alg import collate
class TestAlg(unittest.TestCase):
''' Test cs.logfunctions.
'''
class Klass(object):
def __init__(self, a, b):
self.a = a
self.b = b
def test00nothing(self):
self.assertEqual(collate((), 'foo'), {})
def test01badAttr(self):
O = self.Klass(1, 2)
self.assertRaises(AttributeError, collate, (O,), 'foo')
def test02basic(self):
O1 = self.Klass(1, 2)
O2 = self.Klass(3, 4)
self.assertEqual(collate((O1, O2), 'a'), {1: [O1], 3: [O2]})
def test02basic(self):
O1 = self.Klass(1, 2)
O2 = self.Klass(3, 4)
self.assertEqual(collate((O1, O2), 'a'), {1: [O1], 3: [O2]})
def selftest(argv):
unittest.main(__name__, None, argv)
if __name__ == '__main__':
selftest(sys.argv)