From: Tony Asleson <tasleson@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - lvmdbustest: Utilize addCleanup in unit test
Date: Mon, 19 Sep 2022 15:58:31 +0000 (GMT) [thread overview]
Message-ID: <20220919155831.EF8C8385828E@sourceware.org> (raw)
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b6dc96d8ef03e7af6624ab88a94654ffa94c50ba
Commit: b6dc96d8ef03e7af6624ab88a94654ffa94c50ba
Parent: e977b70bfb0a26a8dd5cd06d581cb810e2a6f10b
Author: Tony Asleson <tasleson@redhat.com>
AuthorDate: Wed Aug 31 18:03:16 2022 -0500
Committer: Tony Asleson <tasleson@redhat.com>
CommitterDate: Fri Sep 16 10:49:37 2022 -0500
lvmdbustest: Utilize addCleanup in unit test
Register the clean up with addCleanup so we ensure clean_up gets run
regardless of what happens in setUp.
---
test/dbus/lvmdbustest.py | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index c932d0830..0d06177c0 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -383,6 +383,9 @@ class DaemonInfo(object):
# noinspection PyUnresolvedReferences
class TestDbusService(unittest.TestCase):
def setUp(self):
+
+ self.addCleanup(self.clean_up)
+
# Because of the sensitive nature of running LVM tests we will only
# run if we have PVs and nothing else, so that we can be confident that
# we are not mucking with someone's data on their system
@@ -463,11 +466,6 @@ class TestDbusService(unittest.TestCase):
# print('Re-creating PV=', p)
self._pv_create(p)
- def tearDown(self):
- # If we get here it means we passed setUp, so lets remove anything
- # and everything that remains, besides the PVs themselves
- self.clean_up()
-
def _check_consistency(self):
# Only do consistency checks if we aren't running the unit tests
# concurrently
reply other threads:[~2022-09-19 15:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220919155831.EF8C8385828E@sourceware.org \
--to=tasleson@sourceware.org \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.