1
0

fix tests: another follow-up to daemon managing Plugins object

In python 3.8 and 3.9, asyncio.Event/Lock/etc cannot be created before the
event loop itself is created. Hence, to have Plugins.__init__ create an
Event, we need to postpone creating Plugins() from setUpClass to setUp.

follow-up 90f39bce88
This commit is contained in:
SomberNight
2023-08-24 18:21:23 +00:00
parent 1dfc1d567b
commit 392f6d8e30

View File

@@ -10,6 +10,8 @@ from electrum.wallet_db import WalletDB
from electrum.wallet import Wallet
from electrum import constants
from electrum import util
from electrum.plugin import Plugins
from electrum.simple_config import SimpleConfig
from . import as_testnet
from .test_wallet import WalletTestCase
@@ -297,25 +299,19 @@ class TestStorageUpgrade(WalletTestCase):
plugins: 'electrum.plugin.Plugins'
@classmethod
def setUpClass(cls):
super().setUpClass()
from electrum.plugin import Plugins
from electrum.simple_config import SimpleConfig
cls.__electrum_path = tempfile.mkdtemp()
config = SimpleConfig({'electrum_path': cls.__electrum_path})
def setUp(self):
super().setUp()
self.__electrum_path = tempfile.mkdtemp()
config = SimpleConfig({'electrum_path': self.__electrum_path})
gui_name = 'cmdline'
# TODO it's probably wasteful to load all plugins... only need Trezor
cls.plugins = Plugins(config, gui_name)
self.plugins = Plugins(config, gui_name)
@classmethod
def tearDownClass(cls):
super().tearDownClass()
shutil.rmtree(cls.__electrum_path)
cls.plugins.stop()
cls.plugins.stopped_event.wait()
def tearDown(self):
super().tearDown()
shutil.rmtree(self.__electrum_path)
self.plugins.stop()
self.plugins.stopped_event.wait()
async def _upgrade_storage(self, wallet_json, accounts=1) -> Optional[WalletDB]:
if accounts == 1: