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

Minor internal fixes #3069

Merged
merged 1 commit into from
Jul 31, 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/3069.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Minor fixes to type hinting in the core tests setup fixtures.
15 changes: 5 additions & 10 deletions tests/core/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import pytest_asyncio

from web3 import (
Web3,
)
from web3.eth import (
AsyncEth,
AsyncWeb3,
)
from web3.module import (
Module,
Expand Down Expand Up @@ -119,18 +116,16 @@ def __init__(self, a, b):
return ModuleManyArgs


@pytest_asyncio.fixture()
@pytest_asyncio.fixture
async def async_w3():
provider = AsyncEthereumTesterProvider()
w3 = Web3(provider, modules={"eth": [AsyncEth]}, middlewares=provider.middlewares)
w3 = AsyncWeb3(AsyncEthereumTesterProvider())
w3.eth.default_account = await w3.eth.coinbase
return w3


@pytest_asyncio.fixture()
@pytest_asyncio.fixture
async def async_w3_non_strict_abi():
provider = AsyncEthereumTesterProvider()
w3 = Web3(provider, modules={"eth": [AsyncEth]}, middlewares=provider.middlewares)
w3 = AsyncWeb3(AsyncEthereumTesterProvider())
w3.strict_bytes_type_checking = False
w3.eth.default_account = await w3.eth.coinbase
return w3
4 changes: 2 additions & 2 deletions tests/core/eth-module/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

from web3 import (
Account,
AsyncWeb3,
Web3,
)
from web3.eth import (
AsyncEth,
BaseEth,
)
from web3.providers.eth_tester import (
Expand Down Expand Up @@ -557,7 +557,7 @@ def test_eth_account_sign_and_send_EIP155_transaction_to_eth_tester(

@pytest.fixture()
def async_w3():
return Web3(AsyncEthereumTesterProvider(), modules={"eth": [AsyncEth]})
return AsyncWeb3(AsyncEthereumTesterProvider())


@patch("web3.eth.BaseEth.account", "wired via BaseEth")
Expand Down
5 changes: 3 additions & 2 deletions tests/core/middleware/test_attrdict_middleware.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest

from web3 import (
AsyncWeb3,
EthereumTesterProvider,
Web3,
)
Expand Down Expand Up @@ -98,7 +99,7 @@ def test_no_attrdict_middleware_does_not_convert_dicts_to_attrdict():

@pytest.mark.asyncio
async def test_async_attrdict_middleware_default_for_async_ethereum_tester_provider():
async_w3 = Web3(AsyncEthereumTesterProvider())
async_w3 = AsyncWeb3(AsyncEthereumTesterProvider())
assert async_w3.middleware_onion.get("attrdict") == async_attrdict_middleware


Expand Down Expand Up @@ -132,7 +133,7 @@ async def test_async_attrdict_middleware_is_recursive(async_w3):

@pytest.mark.asyncio
async def test_no_async_attrdict_middleware_does_not_convert_dicts_to_attrdict():
async_w3 = Web3(AsyncEthereumTesterProvider())
async_w3 = AsyncWeb3(AsyncEthereumTesterProvider())

async_w3.middleware_onion.inject(
await async_construct_result_generator_middleware(
Expand Down