From e462a8914ff8f906ea4d0d5d16f75c9e8e3e93d1 Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 26 Nov 2024 16:43:48 -0500 Subject: [PATCH 1/2] Set maxDiff to None for some TestCase subclasses Omit the ones that don't run any tests but are just used for their setUp and tearDown methods. Signed-off-by: mulhern --- testlib/infra.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/testlib/infra.py b/testlib/infra.py index 479ec86..04cb471 100644 --- a/testlib/infra.py +++ b/testlib/infra.py @@ -238,6 +238,8 @@ class PoolMetadataMonitor(unittest.TestCase): Manage verification of consistency of pool-level metadata. """ + maxDiff = None + def _check_encryption_information_consistency(self, pool_object_path, metadata): """ Check whether D-Bus and metadata agree about encryption state of pool. @@ -302,6 +304,8 @@ class SysfsMonitor(unittest.TestCase): Manage verification of sysfs files for devices. """ + maxDiff = None + def run_check(self): """ Run the check. @@ -339,6 +343,8 @@ class SymlinkMonitor(unittest.TestCase): Manage verification of device symlinks. """ + maxDiff = None + def run_check(self): """ Run the check. @@ -361,6 +367,8 @@ class FilesystemSymlinkMonitor(unittest.TestCase): Verify that devicmapper devices for filesystems have corresponding symlinks. """ + maxDiff = None + def run_check(self, stop_time): """ Check that the filesystem links on the D-Bus and the filesystem links @@ -433,6 +441,8 @@ class DbusMonitor(unittest.TestCase): Manage starting and stopping the D-Bus monitor script. """ + maxDiff = None + def setUp(self): """ Set up the D-Bus monitor for a test run. From 55ba9ccec98ad8cb1d18f6148d05b0376ef847da Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 26 Nov 2024 16:45:34 -0500 Subject: [PATCH 2/2] Do not make RunPostTestChecks inherit from TestCase Aside from the coinciding setUp and tearDown names, it has nothing to do with a TestCase. Signed-off-by: mulhern --- stratis_cli_cert.py | 3 +-- stratisd_cert.py | 3 +-- testlib/infra.py | 12 +++++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/stratis_cli_cert.py b/stratis_cli_cert.py index 9ed7409..4040cc0 100644 --- a/stratis_cli_cert.py +++ b/stratis_cli_cert.py @@ -185,7 +185,6 @@ def setUp(self): super().setUp() self._post_test_checks = RunPostTestChecks() - self._post_test_checks.setUp() def tearDown(self): """ @@ -195,7 +194,7 @@ def tearDown(self): """ super().tearDown() - self._post_test_checks.tearDown() + self._post_test_checks.teardown() def _test_permissions(self, command_line, permissions, exp_stdout_empty): """ diff --git a/stratisd_cert.py b/stratisd_cert.py index bcce509..5f8f55d 100644 --- a/stratisd_cert.py +++ b/stratisd_cert.py @@ -181,7 +181,6 @@ def setUp(self): super().setUp() self._post_test_checks = RunPostTestChecks() - self._post_test_checks.setUp() def tearDown(self): """ @@ -191,7 +190,7 @@ def tearDown(self): """ super().tearDown() - self._post_test_checks.tearDown() + self._post_test_checks.teardown() def _unittest_set_property( self, object_path, param_iface, dbus_param, dbus_value, exception_name diff --git a/testlib/infra.py b/testlib/infra.py index 04cb471..4a746b2 100644 --- a/testlib/infra.py +++ b/testlib/infra.py @@ -597,16 +597,22 @@ def __str__(self): return self.value -class RunPostTestChecks(unittest.TestCase): +class RunPostTestChecks: """ Manage running post test checks """ - def setUp(self): + def __init__(self): + """ + Set up checks that need to be started before test is run. + """ self.dbus_monitor = DbusMonitor() self.dbus_monitor.setUp() - def tearDown(self): + def teardown(self): + """ + Run post-test checks after test is completed. + """ stop_time = time.monotonic_ns() self.dbus_monitor.run_check(stop_time)