本文整理汇总了Python中celery.bin.multi.MultiTool.error方法的典型用法代码示例。如果您正苦于以下问题:Python MultiTool.error方法的具体用法?Python MultiTool.error怎么用?Python MultiTool.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.bin.multi.MultiTool
的用法示例。
在下文中一共展示了MultiTool.error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_MultiTool
# 需要导入模块: from celery.bin.multi import MultiTool [as 别名]
# 或者: from celery.bin.multi.MultiTool import error [as 别名]
class test_MultiTool(AppCase):
def setup(self):
self.fh = WhateverIO()
self.env = {}
self.t = MultiTool(env=self.env, fh=self.fh)
def test_note(self):
self.t.note('hello world')
self.assertEqual(self.fh.getvalue(), 'hello world\n')
def test_note_quiet(self):
self.t.quiet = True
self.t.note('hello world')
self.assertFalse(self.fh.getvalue())
def test_info(self):
self.t.verbose = True
self.t.info('hello info')
self.assertEqual(self.fh.getvalue(), 'hello info\n')
def test_info_not_verbose(self):
self.t.verbose = False
self.t.info('hello info')
self.assertFalse(self.fh.getvalue())
def test_error(self):
self.t.carp = Mock()
self.t.usage = Mock()
self.assertEqual(self.t.error('foo'), 1)
self.t.carp.assert_called_with('foo')
self.t.usage.assert_called_with()
self.t.carp = Mock()
self.assertEqual(self.t.error(), 1)
self.assertFalse(self.t.carp.called)
self.assertEqual(self.t.retcode, 1)
@patch('celery.bin.multi.Popen')
def test_waitexec(self, Popen):
self.t.note = Mock()
pipe = Popen.return_value = Mock()
pipe.wait.return_value = -10
self.assertEqual(self.t.waitexec(['-m', 'foo'], 'path'), 10)
Popen.assert_called_with(['path', '-m', 'foo'], env=self.t.env)
self.t.note.assert_called_with('* Child was terminated by signal 10')
pipe.wait.return_value = 2
self.assertEqual(self.t.waitexec(['-m', 'foo'], 'path'), 2)
self.t.note.assert_called_with(
'* Child terminated with errorcode 2',
)
pipe.wait.return_value = 0
self.assertFalse(self.t.waitexec(['-m', 'foo', 'path']))
def test_nosplash(self):
self.t.nosplash = True
self.t.splash()
self.assertFalse(self.fh.getvalue())
def test_splash(self):
self.t.nosplash = False
self.t.splash()
self.assertIn('celery multi', self.fh.getvalue())
def test_usage(self):
self.t.usage()
self.assertTrue(self.fh.getvalue())
def test_help(self):
self.t.help([])
self.assertIn(doc, self.fh.getvalue())
def test_expand(self):
self.t.expand(['foo%n', 'ask', 'klask', 'dask'])
self.assertEqual(
self.fh.getvalue(), 'fooask\nfooklask\nfoodask\n',
)
def test_restart(self):
stop = self.t._stop_nodes = Mock()
self.t.restart(['jerry', 'george'], 'celery worker')
waitexec = self.t.waitexec = Mock()
self.assertTrue(stop.called)
callback = stop.call_args[1]['callback']
self.assertTrue(callback)
waitexec.return_value = 0
callback('jerry', ['arg'], 13)
waitexec.assert_called_with(['arg'])
self.assertIn('OK', self.fh.getvalue())
self.fh.seek(0)
self.fh.truncate()
waitexec.return_value = 1
callback('jerry', ['arg'], 13)
self.assertIn('FAILED', self.fh.getvalue())
#.........这里部分代码省略.........
示例2: test_MultiTool_functional
# 需要导入模块: from celery.bin.multi import MultiTool [as 别名]
# 或者: from celery.bin.multi.MultiTool import error [as 别名]
class test_MultiTool_functional(AppCase):
def setup(self):
self.fh = WhateverIO()
self.env = {}
self.t = MultiTool(env=self.env, fh=self.fh)
def test_note(self):
self.t.note('hello world')
self.assertEqual(self.fh.getvalue(), 'hello world\n')
def test_note_quiet(self):
self.t.quiet = True
self.t.note('hello world')
self.assertFalse(self.fh.getvalue())
def test_carp(self):
self.t.say = Mock()
self.t.carp('foo')
self.t.say.assert_called_with('foo', True, self.t.stderr)
def test_info(self):
self.t.verbose = True
self.t.info('hello info')
self.assertEqual(self.fh.getvalue(), 'hello info\n')
def test_info_not_verbose(self):
self.t.verbose = False
self.t.info('hello info')
self.assertFalse(self.fh.getvalue())
def test_error(self):
self.t.carp = Mock()
self.t.usage = Mock()
self.assertEqual(self.t.error('foo'), 1)
self.t.carp.assert_called_with('foo')
self.t.usage.assert_called_with()
self.t.carp = Mock()
self.assertEqual(self.t.error(), 1)
self.t.carp.assert_not_called()
def test_nosplash(self):
self.t.nosplash = True
self.t.splash()
self.assertFalse(self.fh.getvalue())
def test_splash(self):
self.t.nosplash = False
self.t.splash()
self.assertIn('celery multi', self.fh.getvalue())
def test_usage(self):
self.t.usage()
self.assertTrue(self.fh.getvalue())
def test_help(self):
self.t.help([])
self.assertIn(doc, self.fh.getvalue())
def test_expand(self):
self.t.expand('foo%n', 'ask', 'klask', 'dask')
self.assertEqual(
self.fh.getvalue(), 'fooask\nfooklask\nfoodask\n',
)
@patch('celery.apps.multi.gethostname')
def test_get(self, gethostname):
gethostname.return_value = 'e.com'
self.t.get('[email protected]', 'foo', 'bar', 'baz')
self.assertFalse(self.fh.getvalue())
self.t.get('[email protected]', 'foo', 'bar', 'baz')
self.assertTrue(self.fh.getvalue())
@patch('celery.apps.multi.gethostname')
def test_names(self, gethostname):
gethostname.return_value = 'e.com'
self.t.names('foo', 'bar', 'baz')
self.assertIn('[email protected]\[email protected]\[email protected]', self.fh.getvalue())
def test_execute_from_commandline(self):
start = self.t.commands['start'] = Mock()
self.t.error = Mock()
self.t.execute_from_commandline(['multi', 'start', 'foo', 'bar'])
self.t.error.assert_not_called()
start.assert_called_with('foo', 'bar')
self.t.error = Mock()
self.t.execute_from_commandline(['multi', 'frob', 'foo', 'bar'])
self.t.error.assert_called_with('Invalid command: frob')
self.t.error = Mock()
self.t.execute_from_commandline(['multi'])
self.t.error.assert_called_with()
self.t.error = Mock()
self.t.execute_from_commandline(['multi', '-foo'])
self.t.error.assert_called_with()
self.t.execute_from_commandline(
#.........这里部分代码省略.........