From c42f0dac53e7d1e27c443b20c51d5d68e8ff8acd Mon Sep 17 00:00:00 2001 From: Filip Gospodinov Date: Thu, 30 Aug 2018 18:53:14 +0200 Subject: [PATCH] test_bitcoin: fix decorators for running tests twice (#4669) This bug is triggered if ecc_fast._libsecp256k1 and/or crypto.AES are not present. Before, if the first test would have raised an exception it would have been implicitly caught by returning from the finally block and hence this effectively masks the test's outcome. Now, the exception is properly propagated causing the test to fail if an exception is raised. --- electrum/tests/test_bitcoin.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/electrum/tests/test_bitcoin.py b/electrum/tests/test_bitcoin.py index c63592d6c..2575ec78f 100644 --- a/electrum/tests/test_bitcoin.py +++ b/electrum/tests/test_bitcoin.py @@ -48,10 +48,10 @@ def needs_test_with_all_ecc_implementations(func): # first test without libsecp func(*args, **kwargs) finally: - # if libsecp is not available, we are done - if not ecc_fast._libsecp256k1: - return ecc_fast.do_monkey_patching_of_python_ecdsa_internals_with_libsecp256k1() + # if libsecp is not available, we are done + if not ecc_fast._libsecp256k1: + return # if libsecp is available, test again now func(*args, **kwargs) return run_test @@ -74,10 +74,10 @@ def needs_test_with_all_aes_implementations(func): # first test without pycryptodomex func(*args, **kwargs) finally: - # if pycryptodomex is not available, we are done - if not _aes: - return crypto.AES = _aes + # if pycryptodomex is not available, we are done + if not _aes: + return # if pycryptodomex is available, test again now func(*args, **kwargs) return run_test