diff --git a/salmon/commands.py b/salmon/commands.py index 42ddad0..db3cff7 100644 --- a/salmon/commands.py +++ b/salmon/commands.py @@ -78,7 +78,7 @@ def inner(fn): @click.group(epilog=copyright_notice) -@click.version_option() +@click.version_option(package_name="salmon-mail", message="%(version)s") def main(): """Python mail server""" pass diff --git a/tests/test_command.py b/tests/test_command.py index 3fd3696..01931f5 100644 --- a/tests/test_command.py +++ b/tests/test_command.py @@ -6,7 +6,7 @@ from click import testing -from salmon import queue, commands, encoding, mail, routing, utils +from salmon import queue, commands, encoding, mail, routing, utils, __version__ as salmon_version from .setup_env import SalmonTestCase @@ -108,6 +108,12 @@ def test_sendmail_command(self, client_mock): runner.invoke(commands.main, ("sendmail", "--host", "127.0.0.1", "--port", "8899", "test@localhost")) self.assertEqual(client_mock.return_value.sendmail.call_count, 1) + def test_version_option(self): + runner = CliRunner() + result = runner.invoke(commands.main, ("--version")) + self.assertEqual(result.exit_code, 0) + self.assertEqual(result.output, f"{salmon_version}\n") + class StartCommandTestCase(SalmonTestCase): @patch('salmon.utils.daemonize')