示例#1
0
 def format_helper(self, initial_content):
     # 1) parse
     reslst, resdct = shvar.load(initial_content)
     # 2) format
     new_content = list(shvar.format(reslst))
     # 3) re parse
     new_reslst, new_resdct = shvar.load(new_content)
     # 4) check
     self.assertEqual([(a,b) for a,b,c in reslst if a], [(a,b) for a,b,c in new_reslst if a])
示例#2
0
 def format_helper(self, initial_content):
     # 1) parse
     reslst, resdct = shvar.load(initial_content)
     # 2) format
     new_content = list(shvar.format(reslst))
     # 3) re parse
     new_reslst, new_resdct = shvar.load(new_content)
     # 4) check
     self.assertEqual([(a,b) for a,b,c in reslst if a], [(a,b) for a,b,c in new_reslst if a])
示例#3
0
 def test_load(self):
     self.assertEqual(shvar.load([]), ([], {}))
     self.assertEqual(shvar.load([" \t\n", "# comment\n", "a=1"]),
                      ([(None, None, ""), (None, None, "# comment"),
                        ('a', "1", "")], {
                            'a': "1"
                        }))
     self.assertEqual(shvar.load(["a=1\n", "a=2\n"]), ([('a', "1", ""),
                                                        ('a', "2", "")], {
                                                            'a': "2"
                                                        }))
示例#4
0
 def load_variable_name_helper(self, varname):
     l, d = shvar.load(["%s=\n" % varname])
     self.assert_(varname in d)
示例#5
0
 def load_empty_helper(self, right_part):
     l, d = shvar.load(["a=%s\n" % right_part])
     self.assertEqual(d['a'], "")
示例#6
0
 def escape_helper(self, to_code):
     line = "A=" + shvar.escape(to_code) + "\n"
     reslst, resdct = shvar.load([line])
     self.assertEqual(resdct['A'], to_code)
示例#7
0
 def load_value_helper(self, right_part, result):
     l, d = shvar.load(["a=%s\n" % right_part])
     self.assertEqual(d['a'], result)
示例#8
0
 def load_variable_name_helper(self, varname):
     l, d = shvar.load(["%s=\n" % varname])
     self.assert_(varname in d)
示例#9
0
 def load_empty_helper(self, right_part):
     l, d = shvar.load(["a=%s\n" % right_part])
     self.assertEqual(d['a'], "")
示例#10
0
 def test_load(self):
     self.assertEqual(shvar.load([]), ([], {}))
     self.assertEqual(shvar.load([" \t\n", "# comment\n", "a=1"]), ([(None, None, ""), (None, None, "# comment"), ('a', "1", "")], {'a': "1"}))
     self.assertEqual(shvar.load(["a=1\n", "a=2\n"]), ([('a', "1", ""), ('a', "2", "")], {'a': "2"}))
示例#11
0
 def escape_helper(self, to_code):
     line = "A=" + shvar.escape(to_code) + "\n"
     reslst, resdct = shvar.load([line])
     self.assertEqual(resdct['A'], to_code)
示例#12
0
 def load_value_helper(self, right_part, result):
     l, d = shvar.load(["a=%s\n" % right_part])
     self.assertEqual(d['a'], result)