summaryrefslogtreecommitdiff
path: root/src/mailman/rules/dmarc.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/rules/dmarc.py')
-rw-r--r--src/mailman/rules/dmarc.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/mailman/rules/dmarc.py b/src/mailman/rules/dmarc.py
index 2739ff937..a213a235b 100644
--- a/src/mailman/rules/dmarc.py
+++ b/src/mailman/rules/dmarc.py
@@ -102,12 +102,13 @@ def ensure_current_suffix_list():
return cached_copy_path
-def parse_suffix_list():
+def parse_suffix_list(filename=None):
# Parse the suffix list into a per process cache.
- cached_copy_path = ensure_current_suffix_list()
+ if filename is None:
+ filename = ensure_current_suffix_list()
# At this point the cached copy must exist and is as valid as possible.
# Read and return the contents as a UTF-8 string.
- with open(cached_copy_path, 'r', encoding='utf-8') as fp:
+ with open(filename, 'r', encoding='utf-8') as fp:
for line in fp:
if not line.strip() or line.startswith('//'):
continue
@@ -121,8 +122,8 @@ def parse_suffix_list():
else:
exception = False
parts.reverse()
- k = DOT.join(parts)
- suffix_cache[k] = exception
+ key = DOT.join(parts)
+ suffix_cache[key] = exception
def _get_dom(d, l):
@@ -227,7 +228,13 @@ def _DMARCProhibited(mlist, email, dmarc_domain, org=False):
if mo:
policy = mo.group(1).lower()
else:
- continue
+ # This continue does actually get covered by
+ # TestDMARCRules.test_domain_with_subdomain_policy() and
+ # TestDMARCRules.test_no_policy() but because of
+ # Coverage BitBucket issue #198 and
+ # http://bugs.python.org/issue2506 coverage cannot report
+ # it as such, so just pragma it away.
+ continue # pragma: no cover
if policy in ('reject', 'quarantine'):
vlog.info(
"""%s: DMARC lookup for %s (%s)