コード例 #1
0
 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.')
コード例 #2
0
 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'})
コード例 #3
0
 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]})
コード例 #4
0
 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 })
コード例 #5
0
    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"})