Skip to content

Commit 425701d

Browse files
committed
test: simplify assert message
1 parent 42e45a0 commit 425701d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

tests/rpc/test_rpc_apiserver.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ def test_api_custom_data_single_trade(botclient, fee):
843843

844844
# Ensure response contains exactly the expected number of entries
845845
assert len(res_cust_data) == len(expected_data_td_1), (
846-
f"\nError: Expected {len(expected_data_td_1)} entries, but got {len(res_cust_data)}.\n"
846+
f"Expected {len(expected_data_td_1)} entries, but got {len(res_cust_data)}.\n"
847847
)
848848

849849
# Validate each expected entry
@@ -855,7 +855,7 @@ def test_api_custom_data_single_trade(botclient, fee):
855855
break
856856

857857
assert matched_item is not None, (
858-
f"\nError: Missing expected entry for key '{expected['key']}'\nExpected: {expected}\n"
858+
f"Missing expected entry for key '{expected['key']}'\nExpected: {expected}\n"
859859
)
860860

861861
# Validate individual fields and print only incorrect values
@@ -864,7 +864,7 @@ def test_api_custom_data_single_trade(botclient, fee):
864864
if matched_item[field] != expected[field]:
865865
mismatches.append(f"{field}: Expected {expected[field]}, Got {matched_item[field]}")
866866

867-
assert not mismatches, f"\nError in entry '{expected['key']}':\n" + "\n".join(mismatches)
867+
assert not mismatches, f"Error in entry '{expected['key']}':\n" + "\n".join(mismatches)
868868

869869
# CASE 2 Checking specific existing key custom data of trade 1
870870
rc = client_get(client, f"{BASE_URI}/trades/1/custom-data?key=test_dict")
@@ -922,9 +922,7 @@ def test_api_custom_data_multiple_open_trades(botclient, fee):
922922
response_json = rc.json()
923923

924924
# Expecting two trade entries in the response
925-
assert len(response_json) == 2, (
926-
f"\nError: Expected 2 trade entries, but got {len(response_json)}.\n"
927-
)
925+
assert len(response_json) == 2, f"Expected 2 trade entries, but got {len(response_json)}.\n"
928926

929927
# Define expected custom data for each trade.
930928
# The keys now use the actual trade_ids from the custom data.
@@ -973,8 +971,8 @@ def test_api_custom_data_multiple_open_trades(botclient, fee):
973971
custom_data_list = trade_entry.get("custom_data")
974972
expected_data = expected_custom_data[trade_id]
975973
assert len(custom_data_list) == len(expected_data), (
976-
f"\nError for trade_id {trade_id}: \
977-
Expected {len(expected_data)} entries, but got {len(custom_data_list)}.\n"
974+
f"Error for trade_id {trade_id}: "
975+
f"Expected {len(expected_data)} entries, but got {len(custom_data_list)}.\n"
978976
)
979977

980978
# For each expected entry, check that the response contains the correct entry.
@@ -986,8 +984,8 @@ def test_api_custom_data_multiple_open_trades(botclient, fee):
986984
break
987985

988986
assert matched_item is not None, (
989-
f"\nError: For trade_id {trade_id}, \
990-
missing expected entry for key '{expected['key']}'\n"
987+
f"For trade_id {trade_id}, "
988+
f"missing expected entry for key '{expected['key']}'\n"
991989
f"Expected: {expected}\n"
992990
)
993991

@@ -1004,7 +1002,7 @@ def test_api_custom_data_multiple_open_trades(botclient, fee):
10041002
mismatches.append(f"Missing field: {field}")
10051003

10061004
assert not mismatches, (
1007-
f"\nError in entry '{expected['key']}' for trade_id {trade_id}:\n"
1005+
f"Error in entry '{expected['key']}' for trade_id {trade_id}:\n"
10081006
+ "\n".join(mismatches)
10091007
)
10101008

0 commit comments

Comments
 (0)