From 1a7d93ab5396a34d6f7d2713d2e0d0015eb8c00d Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Fri, 17 Nov 2023 18:49:11 -0500 Subject: [PATCH] Refactor dm_devices dictionary construction --- testlib/infra.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/testlib/infra.py b/testlib/infra.py index 583b464..1015509 100644 --- a/testlib/infra.py +++ b/testlib/infra.py @@ -176,11 +176,13 @@ class SysfsMonitor(unittest.TestCase): def tearDown(self): if SysfsMonitor.verify_sysfs: # pylint: disable=no-member - dm_devices = {} - for dmdev in os.listdir("/dev/mapper"): - dmdev_path = os.path.join("/dev/mapper", dmdev) - dmdev_num = os.path.basename(os.path.realpath(dmdev_path)) - dm_devices[dmdev_num] = dmdev + dev_mapper = "/dev/mapper" + dm_devices = { + os.path.basename( + os.path.realpath(os.path.join(dev_mapper, dmdev)) + ): dmdev + for dmdev in os.listdir(dev_mapper) + } try: misaligned_devices = []