def test_removeCB(): checkfail(RequireChild(Strong)) tree = setup() sc = SanityChecker() sc.addRule(RequireChild(Strong), removecb) # this removes the sc.check(tree) # now traverse this tree and assert there is no strong for c in tree.allchildren(): assert not isinstance(c, Strong)
def checkfail(*rules): tree = setup() sc = SanityChecker() for r in rules: sc.addRule(r) failed = False try: sc.check(tree) except SanityException: failed = True assert failed
def checkpass(*rules): tree = setup() sc = SanityChecker() for r in rules: sc.addRule(r) sc.check(tree) # should pass