def test_run_command(self): manager = ExecutionManager(stdout=io.StringIO(), stderr=io.StringIO()) class Command(BaseCommand): def run_from_argv(self, argv): self.stdout.write(u'foo') self.stderr.write(u'bar') with mock.patch.object(manager, 'get_command_class') as m: m.return_value = Command manager.run_command('cmd', manager.argv) self.assertEqual(manager.stdout.getvalue(), u'foo') self.assertEqual(manager.stderr.getvalue(), u'bar')
def test_execute_calls_run_command_if_argv_given(self): manager = ExecutionManager(argv=['vcs', 'show', '-h']) manager.run_command = mock.Mock() manager.execute() # we also check argv passed to the command manager.run_command.assert_called_once_with('show', ['vcs', 'show', '-h'])