Browse Source

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
master
SomberNight 2 years ago
parent
commit
392f6d8e30
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 30
      electrum/tests/test_storage_upgrade.py

30
electrum/tests/test_storage_upgrade.py

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

Loading…
Cancel
Save