summaryrefslogtreecommitdiff
path: root/src/mailman/commands/tests/test_cli_shell.py
diff options
context:
space:
mode:
authorBarry Warsaw2017-08-29 14:07:54 +0000
committerBarry Warsaw2017-08-29 14:07:54 +0000
commitae0042a90220119414f61aeb20c6b58bfacb8af2 (patch)
tree6fd2038427fbb36d8173fe338d277351cd19727b /src/mailman/commands/tests/test_cli_shell.py
parentf847e15407bfbf824236547bdf728a1ae00bd405 (diff)
downloadmailman-ae0042a90220119414f61aeb20c6b58bfacb8af2.tar.gz
mailman-ae0042a90220119414f61aeb20c6b58bfacb8af2.tar.zst
mailman-ae0042a90220119414f61aeb20c6b58bfacb8af2.zip
Diffstat (limited to 'src/mailman/commands/tests/test_cli_shell.py')
-rw-r--r--src/mailman/commands/tests/test_cli_shell.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mailman/commands/tests/test_cli_shell.py b/src/mailman/commands/tests/test_cli_shell.py
index ffcf43803..74abd64a3 100644
--- a/src/mailman/commands/tests/test_cli_shell.py
+++ b/src/mailman/commands/tests/test_cli_shell.py
@@ -29,6 +29,7 @@ from mailman.interfaces.usermanager import IUserManager
from mailman.testing.helpers import configuration
from mailman.testing.layers import ConfigLayer
from mailman.utilities.modules import hacked_sys_modules
+from types import ModuleType
from unittest.mock import MagicMock, patch
try:
@@ -40,6 +41,7 @@ except ImportError:
class TestShell(unittest.TestCase):
layer = ConfigLayer
+ maxDiff = None
def setUp(self):
self._command = CliRunner()
@@ -156,12 +158,12 @@ class TestShell(unittest.TestCase):
'Error: No such list: ant.example.com\n')
def test_run_without_listspec(self):
- results = self._command.invoke(shell, ('--run', 'something'))
- self.assertEqual(results.exit_code, 2)
- self.assertEqual(
- results.output,
- 'Usage: shell [OPTIONS] [RUN_ARGS]...\n\n'
- 'Error: --run requires a mailing list\n')
+ something = ModuleType('something')
+ something.something = lambda: print('I am a something!')
+ with hacked_sys_modules('something', something):
+ results = self._command.invoke(shell, ('--run', 'something'))
+ self.assertEqual(results.exit_code, 0)
+ self.assertEqual(results.output, 'I am a something!\n')
def test_run_bogus_listspec(self):
results = self._command.invoke(