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

Mark tests for async test suite more accurately #3180

Merged
merged 4 commits into from
Jan 10, 2024
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/3180.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Re-define how async vs sync core test suites are ran.
4 changes: 2 additions & 2 deletions tests/core/eth-module/test_eth_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)


def test_Eth_filter_creates_correct_filter_type(w3):
def test_eth_filter_creates_correct_filter_type(w3):
filter1 = w3.eth.filter("latest")
assert isinstance(filter1, BlockFilter)
filter2 = w3.eth.filter("pending")
Expand All @@ -41,7 +41,7 @@ async def async_w3():


@pytest.mark.asyncio
async def test_AsyncEth_filter_creates_correct_filter_type(async_w3):
async def test_async_eth_filter_creates_correct_filter_type(async_w3):
filter1 = await async_w3.eth.filter("latest")
assert isinstance(filter1, AsyncBlockFilter)
filter2 = await async_w3.eth.filter("pending")
Expand Down
4 changes: 2 additions & 2 deletions tests/core/providers/test_async_http_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def clean_async_session_cache():


@pytest.mark.asyncio
async def test_no_args() -> None:
async def test_async_no_args() -> None:
provider = AsyncHTTPProvider()
w3 = AsyncWeb3(provider)
assert w3.manager.provider == provider
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_web3_with_async_http_provider_has_default_middlewares_and_modules() ->


@pytest.mark.asyncio
async def test_user_provided_session() -> None:
async def test_async_user_provided_session() -> None:
session = ClientSession()
provider = AsyncHTTPProvider(endpoint_uri=URI)
cached_session = await provider.cache_async_session(session)
Expand Down
22 changes: 11 additions & 11 deletions tests/core/utilities/test_async_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
}


@pytest.mark.asyncio()
async def test_get_block_gas_limit_with_block_number(async_w3):
@pytest.mark.asyncio
async def test_async_get_block_gas_limit_with_block_number(async_w3):
gas_limit = await get_block_gas_limit(async_w3.eth, BlockNumber(0))
assert isinstance(gas_limit, int)


@pytest.mark.asyncio()
async def test_get_block_gas_limit_without_block_number(async_w3):
@pytest.mark.asyncio
async def test_async_get_block_gas_limit_without_block_number(async_w3):
gas_limit = await get_block_gas_limit(async_w3.eth)
assert isinstance(gas_limit, int)


@pytest.mark.asyncio()
async def test_get_buffered_gas_estimate(async_w3):
@pytest.mark.asyncio
async def test_async_get_buffered_gas_estimate(async_w3):
txn_params = {
"data": b"0x1",
}
Expand All @@ -50,8 +50,8 @@ async def test_get_buffered_gas_estimate(async_w3):
assert buffered_gas_estimate == min(gas_estimate + gas_buffer, gas_limit)


@pytest.mark.asyncio()
async def test_fill_transaction_defaults_for_all_params(async_w3):
@pytest.mark.asyncio
async def test_async_fill_transaction_defaults_for_all_params(async_w3):
default_transaction = await async_fill_transaction_defaults(async_w3, {})

block = await async_w3.eth.get_block("latest")
Expand All @@ -68,7 +68,7 @@ async def test_fill_transaction_defaults_for_all_params(async_w3):


@pytest.mark.asyncio()
async def test_fill_transaction_defaults_nondynamic_tranaction_fee(async_w3):
async def test_async_fill_transaction_defaults_nondynamic_tranaction_fee(async_w3):
gasPrice_transaction = {
"gasPrice": 10,
}
Expand All @@ -79,8 +79,8 @@ async def test_fill_transaction_defaults_nondynamic_tranaction_fee(async_w3):
assert none_in_dict(DYNAMIC_FEE_TXN_PARAMS, default_transaction)


@pytest.mark.asyncio()
async def test_fill_transaction_defaults_for_zero_gas_price(async_w3):
@pytest.mark.asyncio
async def test_async_fill_transaction_defaults_for_zero_gas_price(async_w3):
def gas_price_strategy(_w3, tx):
return 0

Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ allowlist_externals=/usr/bin/make
install_command=python -m pip install {opts} {packages}
usedevelop=True
commands=
core: pytest {posargs:tests/core -k "not async"}
core_async: pytest {posargs:tests/core -k async}
core: pytest {posargs:tests/core -m "not asyncio"}
core_async: pytest {posargs:tests/core -m asyncio}
ens: pytest {posargs:tests/ens --ignore=tests/ens/normalization/test_normalize_name_ensip15.py}
ensip15: pytest {posargs:tests/ens/normalization/test_normalize_name_ensip15.py -q}
ethpm: pytest {posargs:tests/ethpm}
Expand Down