python代码写龙卷风_Python中的模拟龙卷风类

我想用单元测试来介绍on_text方法。我想用非unicode消息检查on_text,看看{}被调用了。在class MyTornadoClass(object):

@gen.coroutine

def on_text(self, message):

"""

User message controller

"""

id_ = message.message_id

chat = message.chat

text = message.text.strip().replace(" ", "-").replace("[()&?]", "")

if not self.is_ascii(text):

yield self.send_message(chat.id_, "Sorry, I didn't find anything according to you request. Try again!",

reply_to_message_id=id_)

else:

yield self.perform_search(text, id_, chat)

我的模拟测试是:

^{pr2}$

我收到例外:Traceback (most recent call last):

File "/home/sergei-rudenkov/PycharmProjects/python_tasks/bot_telegram/unit_tests/telezombie_api/starter_test.py", line 21, in test_app

1)

File "/usr/local/lib/python3.5/dist-packages/mock/mock.py", line 925, in assert_called_with

raise AssertionError('Expected call: %s\nNot called' % (expected,))

AssertionError: Expected call: send_message(227071993, "Sorry, I didn't find anything according to you request.\n Try again!", 1)

Not called

----------------------------------------------------------------------

Ran 1 test in 0.006s

FAILED (failures=1)

我不知道我做错了什么。请指出我的错误。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值