本文整理汇总了Python中celery.tests.case.WhateverIO.truncate方法的典型用法代码示例。如果您正苦于以下问题:Python WhateverIO.truncate方法的具体用法?Python WhateverIO.truncate怎么用?Python WhateverIO.truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.tests.case.WhateverIO
的用法示例。
在下文中一共展示了WhateverIO.truncate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_run
# 需要导入模块: from celery.tests.case import WhateverIO [as 别名]
# 或者: from celery.tests.case.WhateverIO import truncate [as 别名]
def test_run(self, real):
out = WhateverIO()
i = inspect(app=self.app, stdout=out)
with self.assertRaises(Error):
i.run()
with self.assertRaises(Error):
i.run('help')
with self.assertRaises(Error):
i.run('xyzzybaz')
i.run('ping')
self.assertTrue(real.called)
i.run('ping', destination='foo,bar')
self.assertEqual(real.call_args[1]['destination'], ['foo', 'bar'])
self.assertEqual(real.call_args[1]['timeout'], 0.2)
callback = real.call_args[1]['callback']
callback({'foo': {'ok': 'pong'}})
self.assertIn('OK', out.getvalue())
instance = real.return_value = Mock()
instance.ping.return_value = None
with self.assertRaises(Error):
i.run('ping')
out.seek(0)
out.truncate()
i.quiet = True
i.say('<-', 'hello')
self.assertFalse(out.getvalue())
示例2: test_run
# 需要导入模块: from celery.tests.case import WhateverIO [as 别名]
# 或者: from celery.tests.case.WhateverIO import truncate [as 别名]
def test_run(self, real):
out = WhateverIO()
i = inspect(app=self.app, stdout=out)
with self.assertRaises(Error):
i.run()
with self.assertRaises(Error):
i.run("help")
with self.assertRaises(Error):
i.run("xyzzybaz")
i.run("ping")
self.assertTrue(real.called)
i.run("ping", destination="foo,bar")
self.assertEqual(real.call_args[1]["destination"], ["foo", "bar"])
self.assertEqual(real.call_args[1]["timeout"], 0.2)
callback = real.call_args[1]["callback"]
callback({"foo": {"ok": "pong"}})
self.assertIn("OK", out.getvalue())
instance = real.return_value = Mock()
instance.ping.return_value = None
with self.assertRaises(Error):
i.run("ping")
out.seek(0)
out.truncate()
i.quiet = True
i.say_chat("<-", "hello")
self.assertFalse(out.getvalue())