本文整理汇总了Python中celery.bin.celery.Command.pretty方法的典型用法代码示例。如果您正苦于以下问题:Python Command.pretty方法的具体用法?Python Command.pretty怎么用?Python Command.pretty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.bin.celery.Command
的用法示例。
在下文中一共展示了Command.pretty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Command
# 需要导入模块: from celery.bin.celery import Command [as 别名]
# 或者: from celery.bin.celery.Command import pretty [as 别名]
class test_Command(AppCase):
def test_Error_repr(self):
x = Error('something happened')
self.assertIsNotNone(x.status)
self.assertTrue(x.reason)
self.assertTrue(str(x))
def setup(self):
self.out = WhateverIO()
self.err = WhateverIO()
self.cmd = Command(self.app, stdout=self.out, stderr=self.err)
def test_error(self):
self.cmd.out = Mock()
self.cmd.error('FOO')
self.cmd.out.assert_called()
def test_out(self):
f = Mock()
self.cmd.out('foo', f)
def test_call(self):
def ok_run():
pass
self.cmd.run = ok_run
self.assertEqual(self.cmd(), EX_OK)
def error_run():
raise Error('error', EX_FAILURE)
self.cmd.run = error_run
self.assertEqual(self.cmd(), EX_FAILURE)
def test_run_from_argv(self):
with self.assertRaises(NotImplementedError):
self.cmd.run_from_argv('prog', ['foo', 'bar'])
def test_pretty_list(self):
self.assertEqual(self.cmd.pretty([])[1], '- empty -')
self.assertIn('bar', self.cmd.pretty(['foo', 'bar'])[1])
def test_pretty_dict(self):
self.assertIn(
'OK',
str(self.cmd.pretty({'ok': 'the quick brown fox'})[0]),
)
self.assertIn(
'ERROR',
str(self.cmd.pretty({'error': 'the quick brown fox'})[0]),
)
def test_pretty(self):
self.assertIn('OK', str(self.cmd.pretty('the quick brown')))
self.assertIn('OK', str(self.cmd.pretty(object())))
self.assertIn('OK', str(self.cmd.pretty({'foo': 'bar'})))
示例2: test_Error_repr
# 需要导入模块: from celery.bin.celery import Command [as 别名]
# 或者: from celery.bin.celery.Command import pretty [as 别名]
class test_Command:
def test_Error_repr(self):
x = Error('something happened')
assert x.status is not None
assert x.reason
assert str(x)
def setup(self):
self.out = WhateverIO()
self.err = WhateverIO()
self.cmd = Command(self.app, stdout=self.out, stderr=self.err)
def test_error(self):
self.cmd.out = Mock()
self.cmd.error('FOO')
self.cmd.out.assert_called()
def test_out(self):
f = Mock()
self.cmd.out('foo', f)
def test_call(self):
def ok_run():
pass
self.cmd.run = ok_run
assert self.cmd() == EX_OK
def error_run():
raise Error('error', EX_FAILURE)
self.cmd.run = error_run
assert self.cmd() == EX_FAILURE
def test_run_from_argv(self):
with pytest.raises(NotImplementedError):
self.cmd.run_from_argv('prog', ['foo', 'bar'])
def test_pretty_list(self):
assert self.cmd.pretty([])[1] == '- empty -'
assert 'bar', self.cmd.pretty(['foo' in 'bar'][1])
def test_pretty_dict(self, text='the quick brown fox'):
assert 'OK' in str(self.cmd.pretty({'ok': text})[0])
assert 'ERROR' in str(self.cmd.pretty({'error': text})[0])
def test_pretty(self):
assert 'OK' in str(self.cmd.pretty('the quick brown'))
assert 'OK' in str(self.cmd.pretty(object()))
assert 'OK' in str(self.cmd.pretty({'foo': 'bar'}))
示例3: test_Command
# 需要导入模块: from celery.bin.celery import Command [as 别名]
# 或者: from celery.bin.celery.Command import pretty [as 别名]
class test_Command(AppCase):
def test_Error_repr(self):
x = Error("something happened")
self.assertIsNotNone(x.status)
self.assertTrue(x.reason)
self.assertTrue(str(x))
def setup(self):
self.out = WhateverIO()
self.err = WhateverIO()
self.cmd = Command(self.app, stdout=self.out, stderr=self.err)
def test_error(self):
self.cmd.out = Mock()
self.cmd.error("FOO")
self.assertTrue(self.cmd.out.called)
def test_out(self):
f = Mock()
self.cmd.out("foo", f)
def test_call(self):
def ok_run():
pass
self.cmd.run = ok_run
self.assertEqual(self.cmd(), EX_OK)
def error_run():
raise Error("error", EX_FAILURE)
self.cmd.run = error_run
self.assertEqual(self.cmd(), EX_FAILURE)
def test_run_from_argv(self):
with self.assertRaises(NotImplementedError):
self.cmd.run_from_argv("prog", ["foo", "bar"])
def test_pretty_list(self):
self.assertEqual(self.cmd.pretty([])[1], "- empty -")
self.assertIn("bar", self.cmd.pretty(["foo", "bar"])[1])
def test_pretty_dict(self):
self.assertIn("OK", str(self.cmd.pretty({"ok": "the quick brown fox"})[0]))
self.assertIn("ERROR", str(self.cmd.pretty({"error": "the quick brown fox"})[0]))
def test_pretty(self):
self.assertIn("OK", str(self.cmd.pretty("the quick brown")))
self.assertIn("OK", str(self.cmd.pretty(object())))
self.assertIn("OK", str(self.cmd.pretty({"foo": "bar"})))