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 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)
@classmethod
def tearDownClass(cls):
super().tearDownClass()
shutil.rmtree(cls.__electrum_path)
cls.plugins.stop()
cls.plugins.stopped_event.wait()
self.plugins = Plugins(config, gui_name)
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:

Loading…
Cancel
Save