def test_documented_examples(rule_text, results, use_re2): rule = AdblockRule(rule_text) rules = AdblockRules([rule_text], use_re2=use_re2) for url in results["blocks"]: assert rule.match_url(url) assert rules.should_block(url) for url in results["doesn't block"]: assert not rule.match_url(url) assert not rules.should_block(url)
def test_rule_with_options(rule_text, results, use_re2): rule = AdblockRule(rule_text) rules = AdblockRules([rule_text], use_re2=use_re2) for url, params, match in results: assert rule.match_url(url, params) == match assert rules.should_block(url, params) == match
def test_rules_instantiation(): rule = AdblockRule("adv") rules = AdblockRules([rule]) assert rule.match_url("http://example.com/adv") assert rules.should_block("http://example.com/adv")