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])
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" }))
def load_variable_name_helper(self, varname): l, d = shvar.load(["%s=\n" % varname]) self.assert_(varname in d)
def load_empty_helper(self, right_part): l, d = shvar.load(["a=%s\n" % right_part]) self.assertEqual(d['a'], "")
def escape_helper(self, to_code): line = "A=" + shvar.escape(to_code) + "\n" reslst, resdct = shvar.load([line]) self.assertEqual(resdct['A'], to_code)
def load_value_helper(self, right_part, result): l, d = shvar.load(["a=%s\n" % right_part]) self.assertEqual(d['a'], result)
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"}))