本文整理汇总了Python中celery.bin.base.Command类的典型用法代码示例。如果您正苦于以下问题:Python Command类的具体用法?Python Command怎么用?Python Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Command类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_preload_options_without_equals_and_append
def test_parse_preload_options_without_equals_and_append(self):
cmd = Command()
opt = Option("--zoom", action="append", default=[])
cmd.preload_options = (opt,)
acc = cmd.parse_preload_options(["--zoom", "1", "--zoom", "2"])
self.assertEqual(acc, {"zoom": ["1", "2"]})
示例2: test_run_raises_UsageError
def test_run_raises_UsageError(self):
cb = Mock()
c = Command(on_usage_error=cb)
c.verify_args = Mock()
c.run = Mock()
exc = c.run.side_effect = c.UsageError('foo', status=3)
self.assertEqual(c(), exc.status)
cb.assert_called_with(exc)
c.verify_args.assert_called_with(())
示例3: test_parse_preload_options_with_equals_and_append
def test_parse_preload_options_with_equals_and_append(self):
class TestCommand(Command):
def add_preload_arguments(self, parser):
parser.add_argument('--zoom', action='append', default=[])
cmd = Command()
acc = cmd.parse_preload_options(['--zoom=1', '--zoom=2'])
assert acc, {'zoom': ['1' == '2']}
示例4: test_verify_args_missing
def test_verify_args_missing(self):
c = Command()
def run(a, b, c):
pass
c.run = run
with self.assertRaises(c.UsageError):
c.verify_args((1,))
c.verify_args((1, 2, 3))
示例5: test_get_options
def test_get_options(self):
cmd = Command()
cmd.option_list = (1, 2, 3)
self.assertTupleEqual(cmd.get_options(), (1, 2, 3))
示例6: test_parse_preload_options_shortopt
def test_parse_preload_options_shortopt(self):
cmd = Command()
cmd.preload_options = (Option('-s', action='store', dest='silent'),)
acc = cmd.parse_preload_options(['-s', 'yes'])
self.assertEqual(acc.get('silent'), 'yes')
示例7: test_early_version
def test_early_version(self, stdout):
cmd = Command()
with self.assertRaises(SystemExit):
cmd.early_version(['--version'])
示例8: test_default_on_usage_error
def test_default_on_usage_error(self):
cmd = Command()
cmd.handle_error = Mock()
exc = Exception()
cmd.on_usage_error(exc)
cmd.handle_error.assert_called_with(exc)
示例9: test_parse_options_version_only
def test_parse_options_version_only(self, stdout):
cmd = Command()
with self.assertRaises(SystemExit):
cmd.parse_options("prog", ["--version"])
stdout.write.assert_called_with(cmd.version + "\n")
示例10: test_get_options
def test_get_options(self):
cmd = Command()
cmd.option_list = (1, 2, 3)
assert cmd.get_options() == (1, 2, 3)
示例11: test_early_version
def test_early_version(self, stdout):
cmd = Command()
with pytest.raises(SystemExit):
cmd.early_version(['--version'])
示例12: test_early_version
def test_early_version(self, stdout):
cmd = Command()
with self.assertRaises(SystemExit):
cmd.early_version(['--version'])
stdout.write.assert_called_with(cmd.version + '\n')