[rhel7-branch 2/5] lvm_test: refactoring + minor fix

wgwoods installerbot-noreply at redhat.com
Thu Oct 8 17:17:41 UTC 2015


From: Will Woods <wwoods at redhat.com>

Factor out a LVMAsRootTestCaseBase so we can more easily add new
functional test cases.

Also fix a buglet in tearDown where a failed pvremove() could make us
exit the loop without finishing.

(cherry picked from commit aa0b60affda67bc1c45cf3c22229448156441f80)

Related: rhbz#1269144
---
 tests/devicelibs_test/lvm_test.py | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/tests/devicelibs_test/lvm_test.py b/tests/devicelibs_test/lvm_test.py
index 375bf32..9b79856 100755
--- a/tests/devicelibs_test/lvm_test.py
+++ b/tests/devicelibs_test/lvm_test.py
@@ -7,6 +7,8 @@
 
 from tests import loopbackedtestcase
 
+# TODO: test cases for lvorigin, lvsnapshot*, thin*
+
 class LVMTestCase(unittest.TestCase):
 
     def testGetPossiblePhysicalExtents(self):
@@ -30,11 +32,11 @@ def testClampSize(self):
 # call if the device is non-existant, and usually that exception is caught and
 # an LVMError is then raised, but not always.
 
-class LVMAsRootTestCase(loopbackedtestcase.LoopBackedTestCase):
+class LVMAsRootTestCaseBase(loopbackedtestcase.LoopBackedTestCase):
 
     def __init__(self, methodName='runTest'):
         """Set up the structure of the volume group."""
-        super(LVMAsRootTestCase, self).__init__(methodName=methodName)
+        super(LVMAsRootTestCaseBase, self).__init__(methodName=methodName)
         self._vg_name = "test-vg"
         self._lv_name = "test-lv"
 
@@ -57,14 +59,17 @@ def tearDown(self):
         except LVMError:
             pass
 
-        try:
-            for dev in self.loopDevices:
+        for dev in self.loopDevices:
+            try:
                 lvm.pvremove(dev)
-        except LVMError:
-            pass
+            except LVMError:
+                pass
+
+        super(LVMAsRootTestCaseBase, self).tearDown()
+
 
-        super(LVMAsRootTestCase, self).tearDown()
 
+class LVMAsRootTestCase(LVMAsRootTestCaseBase):
     def testLVM(self):
         _LOOP_DEV0 = self.loopDevices[0]
         _LOOP_DEV1 = self.loopDevices[1]


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/23f570e508d1fc1504a5b43f145e3fbc162e6f92


More information about the anaconda-patches mailing list