From 36814cc03c950efdb32eadf25f3549fad2efe057 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 2 Sep 2024 09:43:48 +0000 Subject: [PATCH] minor fixes and cleanups --- mmgen/autosign.py | 2 +- test/cmdtest.py | 8 ++++---- test/cmdtest_py_d/ct_autosign.py | 12 ++++++++---- test/include/common.py | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mmgen/autosign.py b/mmgen/autosign.py index 2ccd062d..3cbeb40c 100755 --- a/mmgen/autosign.py +++ b/mmgen/autosign.py @@ -502,7 +502,7 @@ class Autosign: if not silent: msg(f"Mounting '{self.mountpoint}'") else: - die(1,f"Unable to mount device at '{self.mountpoint}'") + die(1,f'Unable to mount device {self.dev_label} at {self.mountpoint}') for dirname in self.dirs: check_or_create(dirname) diff --git a/test/cmdtest.py b/test/cmdtest.py index 875e872b..75141174 100755 --- a/test/cmdtest.py +++ b/test/cmdtest.py @@ -995,14 +995,14 @@ if __name__ == '__main__': tr = CmdTestRunner(data_dir,trash_dir) tr.run_tests(cmd_args) tr.warn_skipped() - if tr.daemon_started: - stop_test_daemons(network_id) + if tr.daemon_started and not cfg.no_daemon_stop: + stop_test_daemons(network_id, remove_datadir=True) if hasattr(tr, 'tg'): del tr.tg del tr except KeyboardInterrupt: - if tr.daemon_started: - stop_test_daemons(network_id) + if tr.daemon_started and not cfg.no_daemon_stop: + stop_test_daemons(network_id, remove_datadir=True) tr.warn_skipped() die(1,yellow('\ntest.py exiting at user request')) except TestSuiteSpawnedScriptException as e: diff --git a/test/cmdtest_py_d/ct_autosign.py b/test/cmdtest_py_d/ct_autosign.py index 7338c36f..edf135b0 100755 --- a/test/cmdtest_py_d/ct_autosign.py +++ b/test/cmdtest_py_d/ct_autosign.py @@ -149,7 +149,9 @@ class CmdTestAutosignBase(CmdTestBase): def _macOS_mount_fs_image(self, loc): time.sleep(0.2) - run(f'hdiutil attach -mountpoint {loc.mountpoint} {loc.fs_image_path}.dmg'.split(), stdout=DEVNULL, check=True) + run( + ['hdiutil', 'attach', '-mountpoint', str(loc.mountpoint), f'{loc.fs_image_path}.dmg'], + stdout=DEVNULL, check=True) def _macOS_eject_disk(self, label): try: @@ -348,6 +350,7 @@ class CmdTestAutosignClean(CmdTestAutosignBase): self.spawn('', msg_only=True) self.insert_device() + silence() self.do_mount() end_silence() @@ -358,7 +361,9 @@ class CmdTestAutosignClean(CmdTestAutosignBase): t = self.spawn('mmgen-autosign', [f'--coins={coins}','clean'], no_msg=True) out = t.read() - self.insert_device() + if sys.platform == 'darwin': + self.insert_device() + silence() self.do_mount() end_silence() @@ -436,8 +441,7 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase): def _wait_signed(self,desc): oqmsg_r(gray(f'→ offline wallet{"s" if desc.endswith("s") else ""} waiting for {desc}')) - assert not self.asi.device_inserted, ( - f'‘{getattr(self.asi, "dev_label_path", self.asi.dev_label)}’ is inserted!') + assert not self.asi.device_inserted, f'‘{self.asi.dev_label}’ is inserted!' assert not self.asi.mountpoint.is_mount(), f'‘{self.asi.mountpoint}’ is mounted!' self.insert_device() while True: diff --git a/test/include/common.py b/test/include/common.py index d076bfd0..fcb79798 100755 --- a/test/include/common.py +++ b/test/include/common.py @@ -420,7 +420,7 @@ class VirtBlockDeviceLinux(VirtBlockDeviceBase): do_run(['sudo', '/sbin/losetup', dev, str(path)]) def do_detach(self, dev, check=True): - do_run(['/sbin/losetup', '-d', dev], check=check) + do_run(['sudo', '/sbin/losetup', '-d', dev], check=check) class VirtBlockDeviceMacOS(VirtBlockDeviceBase):