mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
The few other cases that used SimpleConfig.get_instance() now either get passed a config instance, or they try to get a reference to something else that has a reference to a config. (see lnsweep, qt/qrcodewidget, qt/qrtextedit)
52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
import unittest
|
|
import threading
|
|
import tempfile
|
|
import shutil
|
|
|
|
from electrum import constants
|
|
|
|
|
|
# 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.
|
|
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):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super().setUpClass()
|
|
constants.set_testnet()
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
super().tearDownClass()
|
|
constants.set_mainnet()
|