Skip to content

Commit

Permalink
Some Web3 -> AsyncWeb3 changes for AsyncEthereumTesterProvider tests
Browse files Browse the repository at this point in the history
- Add newsfragment for #3069
  • Loading branch information
fselmo committed Jul 31, 2023
1 parent 0c26e97 commit 6281844
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions newsfragments/3069.internal.rst
@@ -0,0 +1 @@
Minor fixes to type hinting in the core tests setup fixtures.
12 changes: 5 additions & 7 deletions tests/core/conftest.py
Expand Up @@ -3,7 +3,7 @@
import pytest_asyncio

from web3 import (
Web3,
AsyncWeb3,
)
from web3.eth import (
AsyncEth,
Expand Down Expand Up @@ -119,18 +119,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
3 changes: 2 additions & 1 deletion tests/core/eth-module/test_accounts.py
Expand Up @@ -26,6 +26,7 @@

from web3 import (
Account,
AsyncWeb3,
Web3,
)
from web3.eth import (
Expand Down Expand Up @@ -557,7 +558,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
@@ -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

0 comments on commit 6281844

Please sign in to comment.