summaryrefslogtreecommitdiff
path: root/src/mailman/chains/tests/test_headers.py
diff options
context:
space:
mode:
authorBarry Warsaw2016-05-01 19:52:27 -0400
committerBarry Warsaw2016-05-01 19:52:27 -0400
commit7b638b8820c8d5088163a258b7f8960ff580be02 (patch)
tree7c77c101a70110b70ec660d0547a83fa290b2382 /src/mailman/chains/tests/test_headers.py
parent08ec1d488420136db64950673e71d6fbff72e5b7 (diff)
downloadmailman-7b638b8820c8d5088163a258b7f8960ff580be02.tar.gz
mailman-7b638b8820c8d5088163a258b7f8960ff580be02.tar.zst
mailman-7b638b8820c8d5088163a258b7f8960ff580be02.zip
Diffstat (limited to 'src/mailman/chains/tests/test_headers.py')
-rw-r--r--src/mailman/chains/tests/test_headers.py27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/mailman/chains/tests/test_headers.py b/src/mailman/chains/tests/test_headers.py
index 2fa4bfec8..6cd37c988 100644
--- a/src/mailman/chains/tests/test_headers.py
+++ b/src/mailman/chains/tests/test_headers.py
@@ -128,13 +128,10 @@ class TestHeaderChain(unittest.TestCase):
#
# Save the existing rules so they can be restored later.
saved_rules = config.rules.copy()
- next_rule_name = 'header-match-{0:02}'.format(HeaderMatchRule._count)
- config.rules[next_rule_name] = object()
- try:
- self.assertRaises(AssertionError,
- HeaderMatchRule, 'x-spam-score', '.*')
- finally:
- config.rules = saved_rules
+ self.addCleanup(setattr, config, 'rules', saved_rules)
+ HeaderMatchRule('x-spam-score', '*', suffix='100')
+ self.assertRaises(AssertionError,
+ HeaderMatchRule, 'x-spam-score', '.*', suffix='100')
def test_list_rule(self):
# Test that the header-match chain has the header checks from the
@@ -265,19 +262,19 @@ A message body.
header_matches = IHeaderMatchList(self._mlist)
header_matches.append('Header2', 'b+')
header_matches.append('Header3', 'c+')
- def get_links(): # flake8: noqa
+ def get_links(): # noqa
return [
link for link in chain.get_links(self._mlist, Message(), {})
if link.rule.name != 'any'
]
- links = get_links()
- self.assertEqual(len(links), 3)
+ links_1 = get_links()
+ self.assertEqual(len(links_1), 3)
links_2 = get_links()
+ # The link rules both have the same name...
self.assertEqual(
- [l.rule.name for l in links],
+ [l.rule.name for l in links_1],
[l.rule.name for l in links_2],
)
- self.assertEqual(
- [id(l.rule) for l in links],
- [id(l.rule) for l in links_2],
- )
+ # ...and are actually the identical objects.
+ for link1, link2 in zip(links_1, links_2):
+ self.assertIs(link1.rule, link2.rule)