Esempio n. 1
0
 def test_iter(self):
     ast = AST()
     ast['name'] = 'hello'
     ast['name'] = 'world'
     ast['value'] = 1
     self.assertEqual(['name', 'value'], list(ast))
     self.assertEqual([['hello', 'world'], 1], list(ast.values()))
Esempio n. 2
0
 def test_init(self):
     ast = AST()
     data = list(reversed([(0, 0), (1, 2), (2, 4), (3, 6), (4, 8),
                           (5, 10)]))
     for k, v in data:
         ast[k] = v
     self.assertEquals(data, list(ast.items()))
Esempio n. 3
0
    def test_add(self):
        ast = AST()
        ast['name'] = 'hello'
        self.assertIsNotNone(ast.name)
        self.assertEqual('hello', ast.name)

        ast['name'] = 'world'
        self.assertEqual(['hello', 'world'], ast.name)

        ast['value'] = 1
        self.assertEqual(1, ast.value)
Esempio n. 4
0
 def test_empty(self):
     ast = AST()
     self.assertIsNone(ast.name)
Esempio n. 5
0
 def test_ast(self):
     ast = AST()
     self.assertEquals([], list(ast.items()))
     self.assertTrue(hasattr(ast, '__json__'))