async def test_udpsession_response_list_len_mismatch(self): session = UdpTrackerSession("localhost", ("localhost", 4782), "/announce", 0, self.socket_mgr) session.action = 123 session.transaction_id = 123 self.assertFalse(session.is_failed) session._infohash_list = [b"test", b"test2"] self.socket_mgr.response = struct.pack("!iiiii", 123, 123, 0, 1, 2) with self.assertRaises(ValueError): await session.scrape() self.assertTrue(session.is_failed)
async def test_udpsession_response_list_len_mismatch(fake_udp_socket_manager): session = UdpTrackerSession("localhost", ("localhost", 4782), "/announce", 0, None, fake_udp_socket_manager) session.action = 123 session.transaction_id = 123 assert not session.is_failed session._infohash_list = [b"test", b"test2"] fake_udp_socket_manager.response = struct.pack("!iiiii", 123, 123, 0, 1, 2) with pytest.raises(ValueError): await session.scrape() assert session.is_failed await session.cleanup()