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
43
44
45
46
47
48
49
|
import mock
class IndexedDictTest(mock.TestCase):
def setUp(self):
self.setupModules(['_isys'])
def tearDown(self):
self.tearDownModules()
def instantiation_test(self):
from pyanaconda.indexed_dict import IndexedDict
d = IndexedDict()
self.assertIsInstance(d, IndexedDict)
def append_test(self):
from pyanaconda.indexed_dict import IndexedDict
d = IndexedDict()
stored_data = [1, 2, 3]
d["some_step"] = stored_data
self.assertIs(d["some_step"], stored_data)
def cant_append_test(self):
from pyanaconda.indexed_dict import IndexedDict
def assign_int(indexed_dict):
indexed_dict[3] = [1, 2, 3]
d = IndexedDict()
self.assertRaises(TypeError, d.__setitem__, 3, [1, 2, 3])
def referencing_test(self):
from pyanaconda.indexed_dict import IndexedDict
d = IndexedDict()
d["first"] = 10
d["second"] = 20
d["third"] = 30
self.assertEqual(d[0], 10)
self.assertEqual(d[1], 20)
self.assertEqual(d[2], 30)
self.assertRaises(IndexError, d.__getitem__, 3)
def index_test(self):
from pyanaconda.indexed_dict import IndexedDict
d = IndexedDict()
d["first"] = 10
d["second"] = 20
d["third"] = 30
self.assertEqual(d.index("first"), 0)
self.assertEqual(d.index("second"), 1)
self.assertEqual(d.index("third"), 2)
|