summaryrefslogtreecommitdiff
path: root/src/mailman/bin
diff options
context:
space:
mode:
authorJ08nY2017-07-25 21:44:54 +0200
committerJ08nY2017-08-07 17:39:08 +0200
commit8addebbf9802e911c06f6a27b7ffff1e0f1d2e57 (patch)
tree392b50bf726d790102a6036b7aae7e3aa4228720 /src/mailman/bin
parentcc99242654f2bcc11b3a6f124908de4b175c48d4 (diff)
downloadmailman-pluggable-components.tar.gz
mailman-pluggable-components.tar.zst
mailman-pluggable-components.zip
Diffstat (limited to 'src/mailman/bin')
-rw-r--r--src/mailman/bin/mailman.py6
-rw-r--r--src/mailman/bin/master.py2
-rw-r--r--src/mailman/bin/tests/test_mailman.py18
3 files changed, 20 insertions, 6 deletions
diff --git a/src/mailman/bin/mailman.py b/src/mailman/bin/mailman.py
index ece223180..f8006218d 100644
--- a/src/mailman/bin/mailman.py
+++ b/src/mailman/bin/mailman.py
@@ -44,9 +44,9 @@ class Subcommands(click.MultiCommand):
self._commands)
self._loaded = True
- def list_commands(self, ctx):
+ def list_commands(self, ctx): # pragma: nocover
self._load()
- return sorted(self._commands) # pragma: nocover
+ return sorted(self._commands)
def get_command(self, ctx, name):
self._load()
@@ -88,7 +88,7 @@ class Subcommands(click.MultiCommand):
def initialize_config(ctx, param, value):
- if ctx.resilient_parsing:
+ if ctx.resilient_parsing: # pragma: nocover
return
initialize(value)
diff --git a/src/mailman/bin/master.py b/src/mailman/bin/master.py
index a23fb8e0b..ccaa16398 100644
--- a/src/mailman/bin/master.py
+++ b/src/mailman/bin/master.py
@@ -405,7 +405,7 @@ class Loop:
except InterruptedError: # pragma: nocover
# If the system call got interrupted, just restart it.
continue
- if pid not in self._kids:
+ if pid not in self._kids: # pragma: nocover
# Not a runner subprocess, maybe a plugin started one
# ignore it
continue
diff --git a/src/mailman/bin/tests/test_mailman.py b/src/mailman/bin/tests/test_mailman.py
index 54ee54bce..196437291 100644
--- a/src/mailman/bin/tests/test_mailman.py
+++ b/src/mailman/bin/tests/test_mailman.py
@@ -27,6 +27,7 @@ from mailman.config import config
from mailman.database.transaction import transaction
from mailman.testing.layers import ConfigLayer
from mailman.utilities.datetime import now
+from pkg_resources import resource_filename
from unittest.mock import patch
@@ -36,7 +37,19 @@ class TestMailmanCommand(unittest.TestCase):
def setUp(self):
self._command = CliRunner()
- def test_mailman_command_without_subcommand_prints_help(self):
+ def test_mailman_command_config(self):
+ config_path = resource_filename('mailman.testing', 'testing.cfg')
+ with patch('mailman.bin.mailman.initialize') as init:
+ self._command.invoke(main, ('-C', config_path, 'info'))
+ init.assert_called_once_with(config_path)
+
+ def test_mailman_command_no_config(self):
+ with patch('mailman.bin.mailman.initialize') as init:
+ self._command.invoke(main, ('info',))
+ init.assert_called_once_with(None)
+
+ @patch('mailman.bin.mailman.initialize')
+ def test_mailman_command_without_subcommand_prints_help(self, mock):
# Issue #137: Running `mailman` without a subcommand raises an
# AttributeError.
result = self._command.invoke(main)
@@ -46,7 +59,8 @@ class TestMailmanCommand(unittest.TestCase):
# command line.
self.assertEqual(lines[0], 'Usage: main [OPTIONS] COMMAND [ARGS]...')
- def test_mailman_command_with_bad_subcommand_prints_help(self):
+ @patch('mailman.bin.mailman.initialize')
+ def test_mailman_command_with_bad_subcommand_prints_help(self, mock):
# Issue #137: Running `mailman` without a subcommand raises an
# AttributeError.
result = self._command.invoke(main, ('not-a-subcommand',))