diff options
| -rw-r--r-- | src/mailman/config/tests/test_configuration.py | 17 | ||||
| -rw-r--r-- | src/mailman/testing/nose.py | 6 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/mailman/config/tests/test_configuration.py b/src/mailman/config/tests/test_configuration.py index ce2e6bae3..f6bee4209 100644 --- a/src/mailman/config/tests/test_configuration.py +++ b/src/mailman/config/tests/test_configuration.py @@ -32,6 +32,7 @@ import mock import tempfile import unittest +from contextlib import ExitStack from mailman.config.config import ( Configuration, external_configuration, load_external) from mailman.interfaces.configuration import ( @@ -108,8 +109,12 @@ layout: nonesuch # Use a fake sys.exit() function that records that it was called, and # that prevents further processing. config = Configuration() - # Suppress warning messages in the test output. - with self.assertRaises(SystemExit) as cm, mock.patch('sys.stderr'): + # Suppress warning messages in the test output. Also, make sure that + # the config.load() call doesn't break global state. + with ExitStack() as resources: + resources.enter_context(mock.patch('sys.stderr')) + resources.enter_context(mock.patch.object(config, '_clear')) + cm = resources.enter_context(self.assertRaises(SystemExit)) config.load(filename) self.assertEqual(cm.exception.args, (1,)) @@ -125,7 +130,11 @@ layout: nonesuch log_dir: $nopath/log_dir """, file=fp) config = Configuration() - # Suppress warning messages in the test output. - with self.assertRaises(SystemExit) as cm, mock.patch('sys.stderr'): + # Suppress warning messages in the test output. Also, make sure that + # the config.load() call doesn't break global state. + with ExitStack() as resources: + resources.enter_context(mock.patch('sys.stderr')) + resources.enter_context(mock.patch.object(config, '_clear')) + cm = resources.enter_context(self.assertRaises(SystemExit)) config.load(filename) self.assertEqual(cm.exception.args, (1,)) diff --git a/src/mailman/testing/nose.py b/src/mailman/testing/nose.py index 8fe7017c0..8d175873c 100644 --- a/src/mailman/testing/nose.py +++ b/src/mailman/testing/nose.py @@ -116,3 +116,9 @@ class NosePlugin(Plugin): # Suppress the extra "Doctest: ..." line. test.shortDescription = lambda: None event.extraTests.append(test) + + ## def startTest(self, event): + ## import sys; print('vvvvv', event.test, file=sys.stderr) + + ## def stopTest(self, event): + ## import sys; print('^^^^^', event.test, file=sys.stderr) |
