Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up test warnings #2991

Merged
merged 6 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/2991.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove some warnings from test output
5 changes: 4 additions & 1 deletion tests/core/pm-module/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def setup_w3():
w3 = Web3(Web3.EthereumTesterProvider(ethereum_tester=t))
w3.eth.default_account = w3.eth.accounts[0]
w3.eth._default_contract_factory = LinkableContract
w3.enable_unstable_package_management_api()
with pytest.warns(
UserWarning, match="The ``ethPM`` module is no longer being maintained"
):
w3.enable_unstable_package_management_api()
return w3


Expand Down
5 changes: 4 additions & 1 deletion tests/core/pm-module/test_ens_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def ens_setup(deployer):
def ens(ens_setup, mocker):
mocker.patch("web3.middleware.stalecheck._is_fresh", return_value=True)
ens_setup.w3.eth.default_account = ens_setup.w3.eth.coinbase
ens_setup.w3.enable_unstable_package_management_api()
with pytest.warns(
UserWarning, match="The ``ethPM`` module is no longer being maintained"
):
ens_setup.w3.enable_unstable_package_management_api()
return ens_setup


Expand Down
5 changes: 4 additions & 1 deletion tests/core/pm-module/test_registry_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def fresh_w3():
w3 = Web3(Web3.EthereumTesterProvider())
w3.eth.default_account = w3.eth.accounts[0]
w3.eth._default_contract_factory = LinkableContract
w3.enable_unstable_package_management_api()
with pytest.warns(
UserWarning, match="The ``ethPM`` module is no longer being maintained"
):
w3.enable_unstable_package_management_api()
return w3


Expand Down
3 changes: 3 additions & 0 deletions tests/core/utilities/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ async def test_async_json_make_get_request(mocker):
total=10, connect=None, sock_read=None, sock_connect=None
),
)
await session.close()


@pytest.mark.asyncio
Expand All @@ -291,6 +292,7 @@ async def test_async_make_post_request(mocker):
total=10, connect=None, sock_read=None, sock_connect=None
),
)
await session.close()


@pytest.mark.asyncio
Expand Down Expand Up @@ -373,6 +375,7 @@ def target_function(endpoint_uri):
unique_session = event_loop.run_until_complete(
async_cache_and_return_session(endpoint_uri)
)
event_loop.close()
test_sessions.append(unique_session)

threads = []
Expand Down
4 changes: 3 additions & 1 deletion tests/ens/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,9 @@ def async_ENS_registry_factory(async_w3):

@pytest.fixture(scope="session")
def event_loop():
return asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().new_event_loop()
yield loop
loop.close()


# add session scope with above session-scoped `event_loop` for better performance
Expand Down