diff --git a/tests/integration/datanetwork/test_streaming.py b/tests/integration/datanetwork/test_streaming.py index 73df1d713e..c4f826484b 100644 --- a/tests/integration/datanetwork/test_streaming.py +++ b/tests/integration/datanetwork/test_streaming.py @@ -423,6 +423,6 @@ async def test_range_requests_with_blob_lru_cache(self): # running with cache size 0 gets through without errors without # this since the server doesn't stop immediately - await asyncio.sleep(1, loop=self.loop) + await asyncio.sleep(1) await self._request_stream() diff --git a/tests/unit/blob/test_blob_file.py b/tests/unit/blob/test_blob_file.py index ba79230023..ff632adb56 100644 --- a/tests/unit/blob/test_blob_file.py +++ b/tests/unit/blob/test_blob_file.py @@ -36,7 +36,7 @@ async def _test_create_blob(self, blob_class=AbstractBlob, blob_directory=None): writer.write(self.blob_bytes) await blob.verified.wait() self.assertTrue(blob.get_is_verified()) - await asyncio.sleep(0, loop=self.loop) # wait for the db save task + await asyncio.sleep(0) # wait for the db save task return blob async def _test_close_writers_on_finished(self, blob_class=AbstractBlob, blob_directory=None): @@ -48,7 +48,7 @@ async def _test_close_writers_on_finished(self, blob_class=AbstractBlob, blob_di with self.assertRaises(InvalidDataError): writers[1].write(self.blob_bytes * 2) await writers[1].finished - await asyncio.sleep(0, loop=self.loop) + await asyncio.sleep(0) self.assertEqual(4, len(blob.writers)) # write the blob @@ -208,7 +208,7 @@ async def _test_close_reader(self, blob_class=AbstractBlob, blob_directory=None) async def read_blob_buffer(): with reader as read_handle: self.assertEqual(1, len(blob.readers)) - await asyncio.sleep(2, loop=self.loop) + await asyncio.sleep(2) self.assertEqual(0, len(blob.readers)) return read_handle.read() diff --git a/tests/unit/blob_exchange/test_transfer_blob.py b/tests/unit/blob_exchange/test_transfer_blob.py index 4d34c7427d..786793064b 100644 --- a/tests/unit/blob_exchange/test_transfer_blob.py +++ b/tests/unit/blob_exchange/test_transfer_blob.py @@ -183,7 +183,7 @@ async def _inner(): writer.write(mock_blob_bytes) return self.loop.create_task(_inner()) - await asyncio.gather(write_task(writer1), write_task(writer2), loop=self.loop) + await asyncio.gather(write_task(writer1), write_task(writer2)) self.assertDictEqual({1: mock_blob_bytes, 2: mock_blob_bytes}, results) self.assertEqual(1, write_called_count) @@ -270,7 +270,7 @@ async def test_idle_timeout(self): client_blob.delete() # wait for less than the idle timeout - await asyncio.sleep(0.5, loop=self.loop) + await asyncio.sleep(0.5) # download the blob again downloaded, protocol2 = await request_blob(self.loop, client_blob, self.server_from_client.address, @@ -284,10 +284,10 @@ async def test_idle_timeout(self): client_blob.delete() # check that the connection times out from the server side - await asyncio.sleep(0.9, loop=self.loop) + await asyncio.sleep(0.9) self.assertFalse(protocol.transport.is_closing()) self.assertIsNotNone(protocol.transport._sock) - await asyncio.sleep(0.1, loop=self.loop) + await asyncio.sleep(0.1) self.assertIsNone(protocol.transport) def test_max_request_size(self): @@ -323,7 +323,7 @@ async def test_transfer_timeout(self): server_blob = self.server_blob_manager.get_blob(blob_hash) async def sendfile(writer): - await asyncio.sleep(2, loop=self.loop) + await asyncio.sleep(2) return 0 server_blob.sendfile = sendfile @@ -347,7 +347,7 @@ async def test_download_blob_using_jsonrpc_blob_get(self): def _mock_accumulate_peers(q1, q2=None): async def _task(): pass - q2 = q2 or asyncio.Queue(loop=self.loop) + q2 = q2 or asyncio.Queue() return q2, self.loop.create_task(_task()) mock_node.accumulate_peers = _mock_accumulate_peers diff --git a/tests/unit/core/test_utils.py b/tests/unit/core/test_utils.py index 1246e39954..9774dc0d3c 100644 --- a/tests/unit/core/test_utils.py +++ b/tests/unit/core/test_utils.py @@ -72,14 +72,14 @@ def setUp(self): @utils.cache_concurrent async def foo(self, arg1, arg2=None, delay=1): self.called.append((arg1, arg2, delay)) - await asyncio.sleep(delay, loop=self.loop) + await asyncio.sleep(delay) self.counter += 1 self.finished.append((arg1, arg2, delay)) return object() async def test_gather_duplicates(self): result = await asyncio.gather( - self.loop.create_task(self.foo(1)), self.loop.create_task(self.foo(1)), loop=self.loop + self.loop.create_task(self.foo(1)), self.loop.create_task(self.foo(1)) ) self.assertEqual(1, len(self.called)) self.assertEqual(1, len(self.finished)) @@ -93,7 +93,7 @@ async def test_one_cancelled_all_cancel(self): with self.assertRaises(asyncio.CancelledError): await asyncio.gather( - t1, self.loop.create_task(self.foo(1)), loop=self.loop + t1, self.loop.create_task(self.foo(1)) ) self.assertEqual(1, len(self.called)) self.assertEqual(0, len(self.finished)) diff --git a/tests/unit/dht/test_blob_announcer.py b/tests/unit/dht/test_blob_announcer.py index be445aae74..4fb08b9270 100644 --- a/tests/unit/dht/test_blob_announcer.py +++ b/tests/unit/dht/test_blob_announcer.py @@ -128,7 +128,7 @@ async def test_announce_blobs(self): await self.chain_peer(constants.generate_id(current + 4), '1.2.3.13') last = await self.chain_peer(constants.generate_id(current + 5), '1.2.3.14') - search_q, peer_q = asyncio.Queue(loop=self.loop), asyncio.Queue(loop=self.loop) + search_q, peer_q = asyncio.Queue(), asyncio.Queue() search_q.put_nowait(blob1) _, task = last.accumulate_peers(search_q, peer_q) diff --git a/tests/unit/stream/test_managed_stream.py b/tests/unit/stream/test_managed_stream.py index 953eb4c830..28a62d0c25 100644 --- a/tests/unit/stream/test_managed_stream.py +++ b/tests/unit/stream/test_managed_stream.py @@ -89,9 +89,9 @@ async def test_delayed_stop(self): await self._test_transfer_stream(10, stop_when_done=False) self.assertEqual(self.stream.status, "finished") self.assertTrue(self.stream._running.is_set()) - await asyncio.sleep(0.5, loop=self.loop) + await asyncio.sleep(0.5) self.assertTrue(self.stream._running.is_set()) - await asyncio.sleep(2, loop=self.loop) + await asyncio.sleep(2) self.assertEqual(self.stream.status, "finished") self.assertFalse(self.stream._running.is_set()) diff --git a/tests/unit/stream/test_reflector.py b/tests/unit/stream/test_reflector.py index 205de99bd3..ed7494f5b9 100644 --- a/tests/unit/stream/test_reflector.py +++ b/tests/unit/stream/test_reflector.py @@ -86,13 +86,13 @@ async def _test_reflect_stream(self, response_chunk_size=50, partial_needs=False self.assertListEqual(sent, []) async def test_reflect_stream(self): - return await asyncio.wait_for(self._test_reflect_stream(response_chunk_size=50), 3, loop=self.loop) + return await asyncio.wait_for(self._test_reflect_stream(response_chunk_size=50), 3) async def test_reflect_stream_but_reflector_changes_its_mind(self): - return await asyncio.wait_for(self._test_reflect_stream(partial_needs=True), 3, loop=self.loop) + return await asyncio.wait_for(self._test_reflect_stream(partial_needs=True), 3) async def test_reflect_stream_small_response_chunks(self): - return await asyncio.wait_for(self._test_reflect_stream(response_chunk_size=30), 3, loop=self.loop) + return await asyncio.wait_for(self._test_reflect_stream(response_chunk_size=30), 3) async def test_announces(self): to_announce = await self.storage.get_blobs_to_announce() diff --git a/tests/unit/stream/test_stream_manager.py b/tests/unit/stream/test_stream_manager.py index 860bcc5af6..98e3fdd264 100644 --- a/tests/unit/stream/test_stream_manager.py +++ b/tests/unit/stream/test_stream_manager.py @@ -174,7 +174,7 @@ async def _check_post(event): await self.file_manager.download_from_uri(self.uri, self.exchange_rate_manager) else: await self.file_manager.download_from_uri(self.uri, self.exchange_rate_manager) - await asyncio.sleep(0, loop=self.loop) + await asyncio.sleep(0) self.assertTrue(checked_analytics_event) async def test_time_to_first_bytes(self): @@ -317,7 +317,7 @@ async def check_post(event): stream.downloader.node = self.stream_manager.node await stream.save_file() await stream.finished_writing.wait() - await asyncio.sleep(0, loop=self.loop) + await asyncio.sleep(0) self.assertTrue(stream.finished) self.assertFalse(stream.running) self.assertTrue(os.path.isfile(os.path.join(self.client_dir, "test_file"))) @@ -355,7 +355,7 @@ async def check_post(event): self.stream_manager.analytics_manager._post = check_post await self._test_download_error_on_start(expected_error, timeout) - await asyncio.sleep(0, loop=self.loop) + await asyncio.sleep(0) self.assertListEqual([expected_error.__name__], received) async def test_insufficient_funds(self): @@ -448,7 +448,7 @@ async def check_post(event): self.assertDictEqual(self.stream_manager.streams, {}) stream = await self.file_manager.download_from_uri(self.uri, self.exchange_rate_manager) await stream.finished_writing.wait() - await asyncio.sleep(0, loop=self.loop) + await asyncio.sleep(0) await self.stream_manager.stop() self.client_blob_manager.stop() # partial removal, only sd blob is missing.