diff --git a/tests/patched/money.py b/tests/patched/money.py index 7574a195394aae83e9f5775298953cd54b7ce303..067f8151329e7dfbcc3e33623c6145ffd35af27f 100644 --- a/tests/patched/money.py +++ b/tests/patched/money.py @@ -86,10 +86,10 @@ def patched_get_sources(pubkey): max_ud = 0 max_tx = 3 elif pubkey == "HcRgKh4LwbQVYuAc3xAdCynYXpKoiPE6qdxCMa8JeHat": - if patched_get_sources.counter == 0: + if Counter.counter == 0: max_ud = 0 max_tx = 53 - elif patched_get_sources.counter == 1: + elif Counter.counter == 1: listinput.append( InputSource( amount=100 * MAX_INPUTS_PER_TX, # 100 * 46 = 4600 @@ -105,10 +105,10 @@ def patched_get_sources(pubkey): max_ud = 10 max_tx = 0 elif pubkey == "9cwBBgXcSVMT74xiKYygX6FM5yTdwd3NABj1CfHbbAmp": - if patched_get_sources.counter == 0: + if Counter.counter == 0: max_ud = 50 max_tx = 20 - elif patched_get_sources.counter == 1: + elif Counter.counter == 1: listinput.append( InputSource( amount=mock_ud_value * MAX_INPUTS_PER_TX, # 46 UD = 46*314 = 1444 @@ -139,8 +139,9 @@ def patched_get_sources(pubkey): balance = listinput_UD(listinput, balance, pubkey, max_ud) balance = listinput_TX(listinput, balance, max_tx) - patched_get_sources.counter += 1 + Counter.counter += 1 return listinput, balance -patched_get_sources.counter = 0 +class Counter: + counter = 0 diff --git a/tests/test_unit_tx.py b/tests/test_unit_tx.py index 2b940ea0ed6b39b200177cb9bde7d89882446978..0a5db4545105fcda593b6a44de0a2b2807b466e4 100644 --- a/tests/test_unit_tx.py +++ b/tests/test_unit_tx.py @@ -28,7 +28,7 @@ from duniterpy.documents.transaction import ( from patched.auth import patched_auth_method from patched.blockchain_tools import fake_block_id, patched_get_head_block -from patched.money import patched_get_sources, patched_get_ud_value +from patched.money import Counter, patched_get_sources, patched_get_ud_value from patched.test_constants import mock_ud_value from patched.tools import patched_get_currency_symbol from patched.wot import patched_is_member @@ -421,8 +421,8 @@ def test_get_list_input_for_transaction( # patched functions monkeypatch.setattr(money, "get_sources", patched_get_sources) - # reset patched_get_sources counter - patched_get_sources.counter = 0 + # reset Counter.counter + Counter.counter = 0 # testing error exit if isinstance(expected, str): with pytest.raises(SystemExit) as pytest_exit: @@ -830,7 +830,7 @@ def test_handle_intermediaries_transactions( tx, "generate_and_send_transaction", patched_generate_and_send_transaction ) - patched_get_sources.counter = 0 + Counter.counter = 0 # testing tx.handle_intermediaries_transactions( @@ -1025,8 +1025,8 @@ def test_send_transaction( monkeypatch.setattr(money, "get_sources", patched_get_sources) monkeypatch.setattr(money, "get_ud_value", patched_get_ud_value) - # reset patched_get_sources - patched_get_sources.counter = 0 + # reset Counter.counter + Counter.counter = 0 # total amount for pubkey_fifi total_amount = 5300 # compute amounts list