From f00b94f18e1d82d1488cbcee6053f03423bc2f49 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Sat, 22 Jul 2017 03:02:05 +0000 Subject: Convert to click for CLI options --- src/mailman/utilities/tests/test_modules.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/mailman/utilities/tests/test_modules.py') diff --git a/src/mailman/utilities/tests/test_modules.py b/src/mailman/utilities/tests/test_modules.py index 20735486c..82d44cff4 100644 --- a/src/mailman/utilities/tests/test_modules.py +++ b/src/mailman/utilities/tests/test_modules.py @@ -23,7 +23,8 @@ import unittest from contextlib import ExitStack, contextmanager from mailman.interfaces.styles import IStyle -from mailman.utilities.modules import add_components, find_components +from mailman.utilities.modules import ( + add_components, find_components, hacked_sys_modules) from pathlib import Path from tempfile import TemporaryDirectory @@ -228,3 +229,15 @@ class StyleA2: 'previously '): add_components('mypackage', IStyle, {}) + + def test_hacked_sys_modules(self): + self.assertIsNone(sys.modules.get('mailman.not_a_module')) + with hacked_sys_modules('mailman.not_a_module', object()): + self.assertIsNotNone(sys.modules.get('mailman.not_a_module')) + + def test_hacked_sys_modules_restore(self): + email_package = sys.modules['email'] + sentinel = object() + with hacked_sys_modules('email', sentinel): + self.assertEqual(sys.modules.get('email'), sentinel) + self.assertEqual(sys.modules.get('email'), email_package) -- cgit v1.2.3-70-g09d2