def test_removal(): def test(name): print name assert hooks.remove("test_removal", test) is False hooks.add("test_removal", test) assert hooks.remove("test_removal", test) is True
def test_compatibility(): values = [] def test(info): name, = hooks.parse_info(info) values.append(name) hooks.add("test_compatibility", test) hooks.run("test_compatibility", hooks.build_info("str", ("Bobby", ))) hooks.run("test_compatibility", hooks.build_info("str", ("Johnny", ))) assert len(values) == 2 assert values == ["Bobby", "Johnny"]