From f2f91230b23cbed8f636e663e29e6bb4b1dbe9ee Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 1 Jul 2017 14:11:38 -0400 Subject: Added more unit tests for the cmd2.Cmd.select() method Also - Moved the existing tests for select to a more appropriate location - Minor tweak to working in README for readability --- tests/test_transcript.py | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'tests/test_transcript.py') diff --git a/tests/test_transcript.py b/tests/test_transcript.py index a31ebd17..d1363f8e 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -68,13 +68,6 @@ class DemoApp(Cmd): else: self.stdout.write('Hello Nobody\n') - def do_eat(self, arg): - """Eat something, with a selection of sauces to choose from.""" - sauce = self.select('sweet salty', 'Sauce? ') - result = '{food} with {sauce} sauce, yum!' - result = result.format(food=arg, sauce=sauce) - self.stdout.write(result + '\n') - @pytest.fixture def _cmdline_app(): @@ -240,27 +233,6 @@ def test_commands_at_invocation(): assert out == expected -def test_select_options(_demo_app): - # Mock out the input call so we don't actually wait for a user's response on stdin - m = mock.MagicMock(name='input', return_value='2') - sm.input = m - - food = 'bacon' - run_cmd(_demo_app, "set debug true") - out = run_cmd(_demo_app, "eat {}".format(food)) - expected = normalize(""" - 1. sweet - 2. salty -{} with salty sauce, yum! -""".format(food)) - - # Make sure our mock was called with the expected arguments - m.assert_called_once_with('Sauce? ') - - # And verify the expected output to stdout - assert out == expected - - def test_transcript_from_cmdloop(request, capsys): # Create a cmd2.Cmd() instance and make sure basic settings are like we want for test app = CmdLineApp() -- cgit v1.2.1