diff options
| author | Barry Warsaw | 2017-01-04 15:10:55 +0000 |
|---|---|---|
| committer | Barry Warsaw | 2017-01-04 15:10:55 +0000 |
| commit | 9ecb0d462b79bec42e82b6aecea8853262e15753 (patch) | |
| tree | dc422ff2eec850387fcdb7a3c326f8d3a267a16a /src/mailman/testing | |
| parent | 8cb4546b9a2bf87a3e2d465651686ca26a5404db (diff) | |
| parent | ae3eeb642b452ee844ba7a2999361f31c3c327c7 (diff) | |
| download | mailman-9ecb0d462b79bec42e82b6aecea8853262e15753.tar.gz mailman-9ecb0d462b79bec42e82b6aecea8853262e15753.tar.zst mailman-9ecb0d462b79bec42e82b6aecea8853262e15753.zip | |
Merge branch 'dmarc' into 'master'
Implement DMARC mitigations in mailman
Closes #247
See merge request !215
Diffstat (limited to 'src/mailman/testing')
| -rw-r--r-- | src/mailman/testing/documentation.py | 10 | ||||
| -rw-r--r-- | src/mailman/testing/helpers.py | 7 |
2 files changed, 9 insertions, 8 deletions
diff --git a/src/mailman/testing/documentation.py b/src/mailman/testing/documentation.py index 97e30e900..8670f05ef 100644 --- a/src/mailman/testing/documentation.py +++ b/src/mailman/testing/documentation.py @@ -21,7 +21,7 @@ Note that doctest extraction does not currently work for zip file distributions. doctest discovery currently requires file system traversal. """ -from inspect import isfunction, ismethod +from contextlib import ExitStack from mailman.app.lifecycle import create_list from mailman.config import config from mailman.testing.helpers import ( @@ -153,13 +153,9 @@ def setup(testobj): testobj.globs['subscribe'] = subscribe testobj.globs['transaction'] = config.db # Add this so that cleanups can be automatically added by the doctest. - testobj.globs['cleanups'] = [] + testobj.globs['cleanups'] = ExitStack() @public def teardown(testobj): - for cleanup in testobj.globs['cleanups']: - if isfunction(cleanup) or ismethod(cleanup): - cleanup() - else: - cleanup[0](*cleanup[1:]) + testobj.globs['cleanups'].close() diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py index 233b03cf8..290f7e026 100644 --- a/src/mailman/testing/helpers.py +++ b/src/mailman/testing/helpers.py @@ -245,7 +245,7 @@ def get_nntp_server(cleanups): """ patcher = mock.patch('nntplib.NNTP') server_class = patcher.start() - cleanups.append(patcher.stop) + cleanups.callback(patcher.stop) nntpd = server_class() # A class for more convenient access to the posted message. class NNTPProxy: # noqa: E306 @@ -480,6 +480,11 @@ def reset_the_world(): getUtility(IStyleManager).populate() # Remove all dynamic header-match rules. config.chains['header-match'].flush() + # Remove cached organizational domain suffix file. + from mailman.rules.dmarc import LOCAL_FILE_NAME + suffix_file = os.path.join(config.VAR_DIR, LOCAL_FILE_NAME) + with suppress(FileNotFoundError): + os.remove(suffix_file) @public |
