def test_remove_comments(self): self.assertEqual(util.remove_comments("r.act == p.act # comments"), "r.act == p.act") self.assertEqual(util.remove_comments("r.act == p.act#comments"), "r.act == p.act") self.assertEqual(util.remove_comments("r.act == p.act###"), "r.act == p.act") self.assertEqual(util.remove_comments("### comments"), "") self.assertEqual(util.remove_comments("r.act == p.act"), "r.act == p.act")
def add_def(self, sec, key, value): if value == "": return ast = Assertion() ast.key = key ast.value = value if "r" == sec or "p" == sec: ast.tokens = ast.value.split(",") for i,token in enumerate(ast.tokens): ast.tokens[i] = key + "_" + token.strip() else: ast.value = util.remove_comments(util.escape_assertion(ast.value)) if sec not in self.model.keys(): self.model[sec] = {} self.model[sec][key] = ast return True