Barry Warsaw pushed to branch click-cli at mailman / Mailman
Commits: 4f698bf5 by Barry Warsaw at 2017-07-05T22:23:31-04:00 Convert to click. - - - - - 0ab69fa8 by Barry Warsaw at 2017-07-05T22:29:59-04:00 Fix some obvious problems. - - - - - 2 changed files: - src/mailman/commands/tests/test_control.py - src/mailman/commands/tests/test_lists.py Changes: ===================================== src/mailman/commands/tests/test_control.py ===================================== --- a/src/mailman/commands/tests/test_control.py +++ b/src/mailman/commands/tests/test_control.py @@ -45,13 +45,13 @@ def make_config(tmpdir): # runners, but we don't care about any of them, so write a test # configuration file for the master that disables all the runners. new_config = 'no-runners.cfg' - config_file = os.path.join(tmpdir, new_config) + config_file = os.path.join(tmpdir.name, new_config) shutil.copyfile(config.filename, config_file) with open(config_file, 'a') as fp: - print('[paths.here]\npid_file: {}\n\n'.format(pidfile)) + print('[paths.here]\npid_file: {}\n\n'.format(pidfile), file=fp) for runner_config in config.runner_configs: print('[{}]\nstart:no\n'.format(runner_config.name), file=fp) - return config_file + return config_file, pidfile def find_master(): ===================================== src/mailman/commands/tests/test_lists.py ===================================== --- a/src/mailman/commands/tests/test_lists.py +++ b/src/mailman/commands/tests/test_lists.py @@ -19,26 +19,20 @@ import unittest -from io import StringIO +from click.testing import CliRunner from mailman.app.lifecycle import create_list -from mailman.commands.cli_lists import Lists +from mailman.commands.cli_lists import lists from mailman.interfaces.domain import IDomainManager from mailman.testing.layers import ConfigLayer -from unittest.mock import patch from zope.component import getUtility -class FakeArgs: - advertised = False - names = False - descriptions = False - quiet = False - domain = [] - - class TestLists(unittest.TestCase): layer = ConfigLayer + def setUp(self): + self._runner = CliRunner() + def test_lists_with_domain_option(self): # LP: #1166911 - non-matching lists were returned. getUtility(IDomainManager).add( @@ -48,14 +42,8 @@ class TestLists(unittest.TestCase): # Only this one should show up. create_list('te...@example.net') create_list('te...@example.com') - command = Lists() - args = FakeArgs() - args.domain.append('example.net') - output = StringIO() - with patch('sys.stdout', output): - command.process(args) - lines = output.getvalue().splitlines() - # The first line is the heading, so skip that. - lines.pop(0) - self.assertEqual(len(lines), 1, lines) - self.assertEqual(lines[0], 'te...@example.net') + result = self._runner.invoke(lists, ('-d', 'example.net')) + self.assertEqual(result.exit_code, 0) + self.assertEqual( + result.output, + '1 matching mailing lists found:\nte...@example.net\n') View it on GitLab: https://gitlab.com/mailman/mailman/compare/4ec4fbc73cc0f911b8ec7ed3983d09942660a4c4...0ab69fa8471a5f18a9febbfaf55983e3320ad527 --- View it on GitLab: https://gitlab.com/mailman/mailman/compare/4ec4fbc73cc0f911b8ec7ed3983d09942660a4c4...0ab69fa8471a5f18a9febbfaf55983e3320ad527 You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org