11import asyncio
22import logging
33import socket
4- from asyncio import Task
5- from unittest .mock import MagicMock , call , patch
4+ from unittest . mock import call , patch
5+ from unittest .mock import MagicMock
66
77import pytest
88
@@ -17,13 +17,11 @@ def _filter_event(self, event):
1717 return {k : v for k , v in dict (event ).items () if not callable (v )}
1818
1919 def test_data_received (self ):
20- conn , out , proto = self .make_proto ()
20+ _ , out , proto = self .make_proto ()
2121 proto .data_received (
2222 b":server.host COMMAND this is :a command\r \n :server.host PRIVMSG me :hi\r \n "
2323 )
2424
25- conn .loop .run_until_complete (asyncio .gather (* Task .all_tasks (conn .loop )))
26-
2725 assert out == [
2826 {
2927 "chan" : "server.host" ,
@@ -68,24 +66,22 @@ def test_data_received(self):
6866 def make_proto (self ):
6967 conn = MagicMock ()
7068 conn .nick = "me"
71- conn .loop = asyncio .get_event_loop_policy ().new_event_loop ()
69+ conn .loop = conn . bot . loop = asyncio .get_event_loop_policy ().new_event_loop ()
7270 out = []
7371
74- async def func (e ):
72+ def func (e ):
7573 out .append (self ._filter_event (e ))
7674
7775 conn .bot .process = func
7876 proto = irc ._IrcProtocol (conn )
7977 return conn , out , proto
8078
8179 def test_broken_line_doesnt_interrupt (self ):
82- conn , out , proto = self .make_proto ()
80+ _ , out , proto = self .make_proto ()
8381 proto .data_received (
8482 b":server.host COMMAND this is :a command\r \n PRIVMSG\r \n :server.host PRIVMSG me :hi\r \n "
8583 )
8684
87- conn .loop .run_until_complete (asyncio .gather (* Task .all_tasks (conn .loop )))
88-
8985 assert out == [
9086 {
9187 "chan" : "server.host" ,
0 commit comments