1
0

tests: rework testnet

Inheritance was overkill here, and now we can use inheritance for new functionality X
without having to create classes for all combinations of {X, is_testnet}.
This commit is contained in:
SomberNight
2023-02-18 06:44:30 +00:00
parent 72e1be6f5e
commit c5bdd5007c
12 changed files with 66 additions and 48 deletions

View File

@@ -36,8 +36,21 @@ class SequentialTestCase(unittest.TestCase):
class ElectrumTestCase(SequentialTestCase):
"""Base class for our unit tests."""
TESTNET = False
# maxDiff = None
@classmethod
def setUpClass(cls):
super().setUpClass()
if cls.TESTNET:
constants.set_testnet()
@classmethod
def tearDownClass(cls):
super().tearDownClass()
if cls.TESTNET:
constants.set_mainnet()
def setUp(self):
super().setUp()
self.asyncio_loop, self._stop_loop, self._loop_thread = util.create_and_start_event_loop()
@@ -50,20 +63,6 @@ class ElectrumTestCase(SequentialTestCase):
shutil.rmtree(self.electrum_path)
class TestCaseForTestnet(ElectrumTestCase):
"""Class that runs member tests in testnet mode"""
@classmethod
def setUpClass(cls):
super().setUpClass()
constants.set_testnet()
@classmethod
def tearDownClass(cls):
super().tearDownClass()
constants.set_mainnet()
def as_testnet(func):
"""Function decorator to run a single unit test in testnet mode.