Files
pallectrum/electrum/tests/__init__.py

53 lines
1.2 KiB
Python
Raw Normal View History

2018-04-01 15:50:24 +02:00
import unittest
import threading
import tempfile
import shutil
2018-04-01 15:50:24 +02:00
from electrum import constants
2018-04-01 15:50:24 +02:00
# Set this locally to make the test suite run faster.
# If set, unit tests that would normally test functions with multiple implementations,
# will only be run once, using the fastest implementation.
# e.g. libsecp256k1 vs python-ecdsa. pycryptodomex vs pyaes.
2019-05-03 03:13:43 +02:00
FAST_TESTS = False
# some unit tests are modifying globals...
class SequentialTestCase(unittest.TestCase):
test_lock = threading.Lock()
def setUp(self):
super().setUp()
self.test_lock.acquire()
def tearDown(self):
super().tearDown()
self.test_lock.release()
class ElectrumTestCase(SequentialTestCase):
"""Base class for our unit tests."""
def setUp(self):
super().setUpClass()
self.electrum_path = tempfile.mkdtemp()
def tearDown(self):
super().tearDownClass()
shutil.rmtree(self.electrum_path)
class TestCaseForTestnet(ElectrumTestCase):
2018-04-01 15:50:24 +02:00
@classmethod
def setUpClass(cls):
super().setUpClass()
constants.set_testnet()
@classmethod
def tearDownClass(cls):
super().tearDownClass()
constants.set_mainnet()