Skip to content
Closed
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
6 changes: 3 additions & 3 deletions chia/_tests/blockchain/test_augmented_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def test_augmented_chain(default_10000_blocks: list[FullBlock]) -> None:
with pytest.raises(KeyError):
await abc.prev_block_hash([blocks[2].header_hash])

with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await abc.lookup_block_generators(blocks[3].header_hash, {uint32(3)})

block_records = []
Expand All @@ -105,11 +105,11 @@ async def test_augmented_chain(default_10000_blocks: list[FullBlock]) -> None:

assert abc.height_to_block_record(uint32(1)) == block_records[1]

with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await abc.lookup_block_generators(blocks[10].header_hash, {uint32(3), uint32(10)})

# block 1 exists in the chain, but it doesn't have a generator
with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await abc.lookup_block_generators(blocks[1].header_hash, {uint32(1)})

expect_gen = blocks[2].transactions_generator
Expand Down
8 changes: 4 additions & 4 deletions chia/_tests/blockchain/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -4158,24 +4158,24 @@ async def test_lookup_block_generators(
# make sure we don't cross the forks
if clear_cache:
b.clean_block_records()
with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await b.lookup_block_generators(peak_1.prev_header_hash, {uint32(516)})

if clear_cache:
b.clean_block_records()
with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await b.lookup_block_generators(peak_2.prev_header_hash, {uint32(503)})

# make sure we fail when looking up a non-transaction block from the main
# chain, regardless of which chain we start at
if clear_cache:
b.clean_block_records()
with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await b.lookup_block_generators(peak_1.prev_header_hash, {uint32(8)})

if clear_cache:
b.clean_block_records()
with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await b.lookup_block_generators(peak_2.prev_header_hash, {uint32(8)})

# if we try to look up generators starting from a disconnected block, we
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/data_layer/test_data_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2277,7 +2277,7 @@ async def test_unsubscribe_unknown(
bare_data_layer_api: DataLayerRpcApi,
seeded_random: random.Random,
) -> None:
with pytest.raises(RuntimeError, match="No subscription found for the given store_id."):
with pytest.raises(RuntimeError, match="No subscription found for the given store_id"):
await bare_data_layer_api.unsubscribe(request={"id": bytes32.random(seeded_random).hex(), "retain": False})


Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/data_layer/test_data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ async def test_ancestor_table_unique_inserts(data_store: DataStore, store_id: by
hash_2 = bytes32.from_hexstr("924be8ff27e84cba17f5bc918097f8410fab9824713a4668a21c8e060a8cab40")
await data_store._insert_ancestor_table(hash_1, hash_2, store_id, 2)
await data_store._insert_ancestor_table(hash_1, hash_2, store_id, 2)
with pytest.raises(Exception, match="^Requested insertion of ancestor"):
with pytest.raises(Exception, match=r"^Requested insertion of ancestor"):
await data_store._insert_ancestor_table(hash_1, hash_1, store_id, 2)
await data_store._insert_ancestor_table(hash_1, hash_2, store_id, 2)

Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/mempool/test_singleton_fast_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_process_fast_forward_spends_unknown_ff() -> None:
singleton_ff = SingletonFastForward()
# We have no fast forward records yet, so we'll process this coin for the
# first time here, but the item's latest singleton lineage returns None
with pytest.raises(ValueError, match="Cannot proceed with singleton spend fast forward."):
with pytest.raises(ValueError, match="Cannot proceed with singleton spend fast forward"):
singleton_ff.process_fast_forward_spends(
mempool_item=internal_mempool_item, height=TEST_HEIGHT, constants=DEFAULT_CONSTANTS
)
Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/core/test_full_node_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,9 @@ async def test_signage_points(
full_node_service_1.config,
) as client:
# Only provide one
with pytest.raises(ValueError, match="sp_hash or challenge_hash must be provided."):
with pytest.raises(ValueError, match="sp_hash or challenge_hash must be provided"):
await client.get_recent_signage_point_or_eos(None, None)
with pytest.raises(ValueError, match="Either sp_hash or challenge_hash must be provided, not both."):
with pytest.raises(ValueError, match="Either sp_hash or challenge_hash must be provided, not both"):
await client.get_recent_signage_point_or_eos(std_hash(b"0"), std_hash(b"1"))
# Not found
with pytest.raises(ValueError, match="in cache"):
Expand Down
3 changes: 2 additions & 1 deletion chia/_tests/pools/test_pool_cmdline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import json
import re
from dataclasses import dataclass
from io import StringIO
from typing import Optional, cast
Expand Down Expand Up @@ -484,7 +485,7 @@ async def test_plotnft_cli_join(
wallet_id = await create_new_plotnft(wallet_environments)

# Test joining the same pool again
with pytest.raises(click.ClickException, match="already farming to pool http://pool.example.com"):
with pytest.raises(click.ClickException, match=re.escape("already farming to pool http://pool.example.com")):
await JoinPlotNFTCMD(
rpc_info=NeedsWalletRPC(
client_info=client_info,
Expand Down
8 changes: 5 additions & 3 deletions chia/_tests/pools/test_pool_puzzles_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def test_pool_lifecycle(self):
)
# Spend it and hope it fails!
with pytest.raises(
BadSpendBundleError, match="condition validation failure Err.ASSERT_ANNOUNCE_CONSUMED_FAILED"
BadSpendBundleError, match="condition validation failure Err\\.ASSERT_ANNOUNCE_CONSUMED_FAILED"
):
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([singleton_coinsol], G2Element()), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
Expand All @@ -269,7 +269,7 @@ def test_pool_lifecycle(self):
)
# Spend it and hope it fails!
with pytest.raises(
BadSpendBundleError, match="condition validation failure Err.ASSERT_ANNOUNCE_CONSUMED_FAILED"
BadSpendBundleError, match="condition validation failure Err\\.ASSERT_ANNOUNCE_CONSUMED_FAILED"
):
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([singleton_coinsol, bad_coinsol], G2Element()), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
Expand Down Expand Up @@ -320,7 +320,9 @@ def test_pool_lifecycle(self):
(data + singleton.name() + DEFAULT_CONSTANTS.AGG_SIG_ME_ADDITIONAL_DATA),
)
# Spend it and hope it fails!
with pytest.raises(BadSpendBundleError, match="condition validation failure Err.ASSERT_HEIGHT_RELATIVE_FAILED"):
with pytest.raises(
BadSpendBundleError, match="condition validation failure Err\\.ASSERT_HEIGHT_RELATIVE_FAILED"
):
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([return_coinsol], sig), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/pools/test_pool_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ async def test_join_pool_unsynced(
mock.return_value = False

# Test joining the same pool via the RPC client
with pytest.raises(ResponseFailureError, match="Wallet needs to be fully synced."):
with pytest.raises(ResponseFailureError, match="Wallet needs to be fully synced"):
await wallet_rpc.pw_join_pool(
PWJoinPool(
wallet_id=uint32(wallet_id),
Expand Down
20 changes: 10 additions & 10 deletions chia/_tests/util/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_split_manager_raises_on_second_entry() -> None:
split = SplitManager(manager=sync_manager(y=x), object=None)
split.enter()

with pytest.raises(Exception, match="^already entered$"):
with pytest.raises(Exception, match=r"^already entered$"):
split.enter()


Expand All @@ -193,7 +193,7 @@ def test_split_manager_raises_on_second_entry_after_exiting() -> None:
split.enter()
split.exit()

with pytest.raises(Exception, match="^already entered, already exited$"):
with pytest.raises(Exception, match=r"^already entered, already exited$"):
split.enter()


Expand All @@ -204,7 +204,7 @@ def test_split_manager_raises_on_second_exit() -> None:
split.enter()
split.exit()

with pytest.raises(Exception, match="^already exited$"):
with pytest.raises(Exception, match=r"^already exited$"):
split.exit()


Expand All @@ -213,7 +213,7 @@ def test_split_manager_raises_on_exit_without_entry() -> None:

split = SplitManager(manager=sync_manager(y=x), object=None)

with pytest.raises(Exception, match="^not yet entered$"):
with pytest.raises(Exception, match=r"^not yet entered$"):
split.exit()


Expand Down Expand Up @@ -274,7 +274,7 @@ async def test_split_async_manager_raises_on_second_entry() -> None:
split = SplitAsyncManager(manager=async_manager(y=x), object=None)
await split.enter()

with pytest.raises(Exception, match="^already entered$"):
with pytest.raises(Exception, match=r"^already entered$"):
await split.enter()


Expand All @@ -286,7 +286,7 @@ async def test_split_async_manager_raises_on_second_entry_after_exiting() -> Non
await split.enter()
await split.exit()

with pytest.raises(Exception, match="^already entered, already exited$"):
with pytest.raises(Exception, match=r"^already entered, already exited$"):
await split.enter()


Expand All @@ -298,7 +298,7 @@ async def test_split_async_manager_raises_on_second_exit() -> None:
await split.enter()
await split.exit()

with pytest.raises(Exception, match="^already exited$"):
with pytest.raises(Exception, match=r"^already exited$"):
await split.exit()


Expand All @@ -308,7 +308,7 @@ async def test_split_async_manager_raises_on_exit_without_entry() -> None:

split = SplitAsyncManager(manager=async_manager(y=x), object=None)

with pytest.raises(Exception, match="^not yet entered$"):
with pytest.raises(Exception, match=r"^not yet entered$"):
await split.exit()


Expand Down Expand Up @@ -390,7 +390,7 @@ async def test_valued_event_set_again_raises_and_does_not_change_value() -> None
value = 37
valued_event.set(value)

with pytest.raises(Exception, match="^Value already set$"):
with pytest.raises(Exception, match=r"^Value already set$"):
valued_event.set(value + 1)

with anyio.fail_after(adjusted_timeout(10)):
Expand All @@ -404,7 +404,7 @@ async def test_valued_event_wait_raises_if_not_set() -> None:
valued_event = ValuedEvent[int]()
valued_event._event.set()

with pytest.raises(Exception, match="^Value not set despite event being set$"):
with pytest.raises(Exception, match=r"^Value not set despite event being set$"):
with anyio.fail_after(adjusted_timeout(10)):
await valued_event.wait()

Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/wallet/cat_wallet/test_cat_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ async def check_all_there() -> bool:
assert action_scope.side_effects.transactions[0].amount == uint64(max_sent_amount)

# 3) Generate transaction that is greater than limit
with pytest.raises(ValueError, match="Can't select amount higher than our spendable balance."):
with pytest.raises(ValueError, match="Can't select amount higher than our spendable balance"):
async with cat_wallet.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=False
) as action_scope:
Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/wallet/did_wallet/test_did.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ async def test_get_info(wallet_environments: WalletTestFramework):
coin = (await wallet_0.select_coins(uint64(1), action_scope)).pop()
assert coin.amount % 2 == 1
coin_id = coin.name()
with pytest.raises(ValueError, match="The coin is not a DID."):
with pytest.raises(ValueError, match="The coin is not a DID"):
await api_0.get_did_info(DIDGetInfo(coin_id.hex()))

# Test multiple odd coins
Expand Down Expand Up @@ -845,7 +845,7 @@ async def test_get_info(wallet_environments: WalletTestFramework):
]
)

with pytest.raises(ValueError, match="This is not a singleton, multiple children coins found."):
with pytest.raises(ValueError, match=r"This is not a singleton, multiple children coins found."):
await api_0.get_did_info(DIDGetInfo(coin_1.name().hex()))


Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/wallet/nft_wallet/test_nft_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ async def test_nft_wallet_creation_and_transfer(wallet_environments: WalletTestF
await time_out_assert(30, get_nft_count, 1, nft_wallet_1)

# Test an error case
with pytest.raises(ResponseFailureError, match="The NFT doesn't support setting a DID."):
with pytest.raises(ResponseFailureError, match="The NFT doesn't support setting a DID"):
await env_1.rpc_client.set_nft_did(
NFTSetNFTDID(
wallet_id=uint32(env_1.wallet_aliases["nft"]),
Expand Down Expand Up @@ -659,7 +659,7 @@ async def test_nft_wallet_rpc_creation_and_list(wallet_environments: WalletTestF
# test counts
assert (await env.rpc_client.count_nfts(NFTCountNFTs(uint32(env.wallet_aliases["nft"])))).count == 2
assert (await env.rpc_client.count_nfts(NFTCountNFTs())).count == 2
with pytest.raises(ResponseFailureError, match="Wallet 50 not found."):
with pytest.raises(ResponseFailureError, match=r"Wallet 50 not found."):
await env.rpc_client.count_nfts(NFTCountNFTs(uint32(50)))


Expand Down
1 change: 0 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ ignore = [
"RUF056", # falsy-dict-get-fallback
# Should probably fix this
"RUF029", # unused-async
"RUF043", # pytest-raises-ambiguous-pattern
"RUF046", # unnecessary-cast-to-int
"RUF052", # used-dummy-variable

Expand Down
Loading