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:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user