tests: use config.path instead of electrum_path for network-aware test dirs
SimpleConfig.path differs from electrum_path when the active network has a subdirectory (e.g. BitcoinPurple mainnet). Tests that wrote directly to electrum_path were resolving the wrong directory; use config.path consistently. Also reorder setUp() so config is created before any path-dependent operations
This commit is contained in:
@@ -57,9 +57,9 @@ class TestBlockchain(ElectrumTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.data_dir = self.electrum_path
|
||||
self.config = SimpleConfig({'electrum_path': self.electrum_path})
|
||||
self.data_dir = self.config.path
|
||||
make_dir(os.path.join(self.data_dir, 'forks'))
|
||||
self.config = SimpleConfig({'electrum_path': self.data_dir})
|
||||
blockchain.blockchains = {}
|
||||
|
||||
def _append_header(self, chain: Blockchain, header: dict):
|
||||
|
||||
@@ -197,7 +197,7 @@ class TestCommandsTestnet(ElectrumTestCase):
|
||||
super().setUp()
|
||||
self.config = SimpleConfig({'electrum_path': self.electrum_path})
|
||||
self.config.NETWORK_OFFLINE = True
|
||||
shutil.copytree(os.path.join(os.path.dirname(__file__), "fiat_fx_data"), os.path.join(self.electrum_path, "cache"))
|
||||
shutil.copytree(os.path.join(os.path.dirname(__file__), "fiat_fx_data"), os.path.join(self.config.path, "cache"))
|
||||
self.config.FX_EXCHANGE = "BitFinex"
|
||||
self.config.FX_CURRENCY = "EUR"
|
||||
self._default_default_timezone = electrum.util.DEFAULT_TIMEZONE
|
||||
|
||||
@@ -107,7 +107,7 @@ class Test_SimpleConfig(ElectrumTestCase):
|
||||
read_user_dir_function=read_user_dir)
|
||||
config.save_user_config()
|
||||
contents = None
|
||||
with open(os.path.join(self.electrum_dir, "config"), "r") as f:
|
||||
with open(os.path.join(config.path, "config"), "r") as f:
|
||||
contents = f.read()
|
||||
result = ast.literal_eval(contents)
|
||||
result.pop('config_version', None)
|
||||
|
||||
@@ -225,8 +225,8 @@ class TestHistoryExport(ElectrumTestCase):
|
||||
self.patch_timezone.start()
|
||||
time.tzset()
|
||||
super(TestHistoryExport, self).setUp()
|
||||
shutil.copytree(Path(__file__).parent / "fiat_fx_data", Path(self.electrum_path) / "cache")
|
||||
self.config = SimpleConfig({'electrum_path': self.electrum_path})
|
||||
shutil.copytree(Path(__file__).parent / "fiat_fx_data", Path(self.config.path) / "cache")
|
||||
|
||||
def tearDown(self):
|
||||
super(TestHistoryExport, self).tearDown()
|
||||
|
||||
Reference in New Issue
Block a user