def test_dict_error(self): """ dict error """ the_string = "{'a':1, b:2 " compiler = Compiler() try: compiler.compile_dict(the_string) except CompilerError, err: self.assertEqual(err.message, 'Expression "{\'a\':1, b:2 " cannot be converted as a dict.')
def test_noquotes_dict(self): """ no quotes dict """ the_string = "{ no12: a b , no10:a}" compiler = Compiler() the_result = compiler.compile_dict(the_string) self.assertEqual(the_result, { 'no12': 'a b' , 'no10':'a'})
def test_dict_with_list(self): """ dict with list """ the_string = "{'a':1, b:[1,2,3,4,5] }" compiler = Compiler() the_result = compiler.compile_dict(the_string) self.assertEqual(the_result, {'a':1, 'b':[1, 2, 3, 4, 5]})
def test_simple_dict(self): """ simple dict """ the_string = "{'a':1, b:2 }" compiler = Compiler() the_result = compiler.compile_dict(the_string) self.assertEqual(the_result, {'a':1, 'b':2 })
def test_noquotes_dict(self): """ no quotes dict """ the_string = "{ no12: a b , no10:a}" compiler = Compiler() the_result = compiler.compile_dict(the_string) self.assertEqual(the_result, {"no12": "a b", "no10": "a"})