运行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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...