From 5c406683b83bbe86df5d07903d2a74c98ae543ca Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Tue, 5 May 2026 09:43:18 +0200 Subject: [PATCH] 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 --- tests/test_blockchain.py | 4 ++-- tests/test_commands.py | 2 +- tests/test_simple_config.py | 2 +- tests/test_wallet.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_blockchain.py b/tests/test_blockchain.py index aaf6ca306..0e9cf1a2d 100644 --- a/tests/test_blockchain.py +++ b/tests/test_blockchain.py @@ -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): diff --git a/tests/test_commands.py b/tests/test_commands.py index f294c6da5..d67480733 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -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 diff --git a/tests/test_simple_config.py b/tests/test_simple_config.py index 6b8ade704..9d5fc73de 100644 --- a/tests/test_simple_config.py +++ b/tests/test_simple_config.py @@ -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) diff --git a/tests/test_wallet.py b/tests/test_wallet.py index de1a278a6..e4ddef3be 100644 --- a/tests/test_wallet.py +++ b/tests/test_wallet.py @@ -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()