Fix Decimal serialization in subTest for pytest-xdist
The parallel test execution failed on 4 tests because pytest-xdist's execnet cannot serialize Decimal objects when sending test results between workers. Solution: Convert Decimal objects to strings in subTest() parameters. The Decimal values are still used for actual test logic, but the subTest labels now use string representations. Fixed tests: - test_sweep_restocking_fee_fee_amount_calculation - test_doge_expected_amount_precision_always_rounds_up - test_xmr_expected_amount_precision_always_rounds_up - test_fee_calculations_always_round_up This is a common pytest-xdist limitation with non-serializable types.
This commit is contained in:
parent
af4b70a160
commit
6d40232fe4
1 changed files with 4 additions and 4 deletions
|
|
@ -2849,7 +2849,7 @@ class SweepRestockingFeeTests(unittest.TestCase):
|
|||
]
|
||||
|
||||
for fee_amount, coin_type, expected_atomic in test_cases:
|
||||
with self.subTest(fee_amount=fee_amount, coin_type=coin_type):
|
||||
with self.subTest(fee_amount=str(fee_amount), coin_type=coin_type):
|
||||
payment = MagicMock()
|
||||
payment.coin_type = coin_type
|
||||
payment.shop_sweep_to_address = None # Will skip actual sweep
|
||||
|
|
@ -4913,7 +4913,7 @@ class CryptoPrecisionTests(unittest.TestCase):
|
|||
]
|
||||
|
||||
for amount in test_cases:
|
||||
with self.subTest(amount=amount):
|
||||
with self.subTest(amount=str(amount)):
|
||||
# This is how crypto.py calculates expected amounts
|
||||
expected_koinu = math.ceil(amount * 100_000_000)
|
||||
|
||||
|
|
@ -4937,7 +4937,7 @@ class CryptoPrecisionTests(unittest.TestCase):
|
|||
]
|
||||
|
||||
for amount in test_cases:
|
||||
with self.subTest(amount=amount):
|
||||
with self.subTest(amount=str(amount)):
|
||||
# This is how crypto.py calculates expected amounts
|
||||
expected_piconero = math.ceil(amount * 1_000_000_000_000)
|
||||
|
||||
|
|
@ -4992,7 +4992,7 @@ class CryptoPrecisionTests(unittest.TestCase):
|
|||
]
|
||||
|
||||
for fee in test_fees:
|
||||
with self.subTest(fee=fee):
|
||||
with self.subTest(fee=str(fee)):
|
||||
# DOGE fee calculation
|
||||
doge_fee_koinu = math.ceil(fee * 100_000_000)
|
||||
naive_doge_fee = int(fee * 100_000_000)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue