@@ -42,6 +42,19 @@ def test_bad_regexp(tree):
4242 return False
4343 return True
4444
45+ def test_missing_to (tree ):
46+
47+ # Rules that are terminated before setting 'to'.
48+ # These cases are probably due to either a misplaced
49+ # rule end or intended to be different elements.
50+ """Rule is missing a 'to' value."""
51+ for rule in tree .xpath ("/ruleset/rule" ):
52+ if not rule .get ("to" ):
53+ sys .stdout .write ("warning: 'to' attribute missing in %s. " % fi )
54+ sys .stdout .write ("Misplaced end or misnamed element?\n " )
55+ return False
56+ return True
57+
4558def test_unescaped_dots (tree ):
4659 # Rules containing unescaped dots outside of brackets and before slash.
4760 # Note: this is meant to require example\.com instead of example.com,
@@ -149,7 +162,7 @@ def test_non_ascii(tree):
149162 return False
150163 return True
151164
152- tests = [test_not_anchored , test_bad_regexp , test_unescaped_dots ,
165+ tests = [test_not_anchored , test_bad_regexp , test_unescaped_dots , test_missing_to ,
153166 test_space_in_to , test_unencrypted_to , test_backslash_in_to ,
154167 test_no_trailing_slash , test_lacks_target_host , test_bad_target_host ,
155168 test_duplicated_target_host , test_non_ascii ]
0 commit comments