如何解决运行Django频道测试
我正在为Django通道编写测试,但是它抛出KeyError: path
。频道版本为1.1.6
routing.py
channel_routing = [
route_class(ChatConsumer),]
consumers.py
@channel_session
def connect(self,message,**kwargs):
message.reply_channel.send({"accept": True})
Group('users').add(message.reply_channel)
@channel_session
def receive(self,data=None,**kwargs):
if data.get('type') == 'typing':
self.typing(data)
test.py
class ChannelTestCases(ChannelTestCase):
# def test_a_thing(self):
# # This goes onto an in-memory channel,not the real backend.
# Channel("some-channel-name").send({"foo": "bar"})
def test_consumer(self):
Channel("typing").send({"type": "typing"})
ChatConsumer(self.get_next_message("typing",require=True))
result = self.get_next_message("result",require=True)
self.assertEqual(result['value'],1089)
请问有人可以帮助我测试此案吗?一般来说,我是通过查看文档来完成的。我做对了吗?任何帮助,将不胜感激!预先感谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。