From 7a7445acf391785aec86c3412d2d928f789e7ca2 Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Sat, 12 Oct 2024 13:43:29 -0700 Subject: [PATCH] tests/beacon: use fixture for user_defined_request_timeout tests This fixes the following warning: tests/beacon/test_async_beacon.py::test_async_beacon_user_request_timeout /home/lukas/Documents/git/web3.py/venv/lib64/python3.13/site-packages/aiohttp/client.py:417: ResourceWarning: Unclosed client session The change to the syncronous beacon class test is just to make it uniform Signed-off-by: Lukas Rusak --- tests/beacon/test_async_beacon.py | 6 +++--- tests/beacon/test_beacon.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/beacon/test_async_beacon.py b/tests/beacon/test_async_beacon.py index 945629b382..96cc5e75c3 100644 --- a/tests/beacon/test_async_beacon.py +++ b/tests/beacon/test_async_beacon.py @@ -46,10 +46,10 @@ async def test_async_cl_beacon_raises_exception_on_invalid_url(async_beacon): @pytest.mark.asyncio -async def test_async_beacon_user_request_timeout(): - beacon = AsyncBeacon(base_url=BASE_URL, request_timeout=0.001) +async def test_async_beacon_user_request_timeout(async_beacon): + async_beacon.request_timeout = 0.001 with pytest.raises(TimeoutError): - await beacon.get_validators() + await async_beacon.get_validators() # Beacon endpoint tests: diff --git a/tests/beacon/test_beacon.py b/tests/beacon/test_beacon.py index 63d71fcafd..65fa942c5e 100644 --- a/tests/beacon/test_beacon.py +++ b/tests/beacon/test_beacon.py @@ -35,8 +35,8 @@ def test_cl_beacon_raises_exception_on_invalid_url(beacon): beacon._make_get_request(BASE_URL + "/eth/v1/beacon/nonexistent") -def test_beacon_user_defined_request_timeout(): - beacon = Beacon(base_url=BASE_URL, request_timeout=0.001) +def test_beacon_user_defined_request_timeout(beacon): + beacon.request_timeout = 0.001 with pytest.raises(Timeout): beacon.get_validators()