def test_execute(self): command = BaseCommand() command.handle = mock.Mock() args = ['bar'] kwargs = {'debug': True} command.execute(*args, **kwargs) command.handle.assert_called_once_with(*args, **kwargs)
def test_run_from_argv(self): command = BaseCommand() argv = ['vcs', 'foo', '--debug', 'bar', '--traceback'] command.handle = mock.Mock() command.run_from_argv(argv) args = ['bar'] kwargs = {'debug': True, 'traceback': True} command.handle.assert_called_once_with(*args, **kwargs)
def test_usage(self): command = BaseCommand() command.args = 'foo' self.assertEqual(command.usage('bar'), '%prog bar [options] foo')
def test_get_version(self): command = BaseCommand() self.assertEqual(command.get_version(), vcs.get_version())
def test_default_stderr(self): stream = StringIO() with mock.patch.object(sys, 'stderr', stream): command = BaseCommand() command.stderr.write(u'foobar') self.assertEqual(sys.stderr.getvalue(), u'foobar')