def testinitstring(self): params = Dictionary("a=1 b=2 c=3") self.assertEqual(params['a'], 1) self.assertEqual(params['b'], 2) self.assertEqual(params['c'], 3) self.assertEqual(params.keys(), ["a", "b", "c"]) self.assertEqual(params.values(), [1, 2, 3])
def testcopy(self): params = Dictionary('a="one two" b="2.943"') params2 = params.copy() from copy import copy params3 = copy(params) self.assertEqual(params.keys(), params2.keys()) self.assertEqual(params.values(), params2.values()) self.assertEqual(params.values(), params3.values())
def testinitdictionary(self): p1 = Dictionary("a=1 b=2 c=3") p2 = Dictionary(p1) self.assertEqual(p2['a'], 1) self.assertEqual(p2['b'], 2) self.assertEqual(p2['c'], 3) self.assertEqual(p2.keys(), ["a", "b", "c"]) self.assertEqual(p2.values(), [1, 2, 3])
def testinitlines(self): lines = ['a=1\n', 'b=2\n'] p = Dictionary(lines) self.assertEqual(p.keys(), ['a', 'b']) self.assertEqual(p.values(), [1, 2])