[PATCH blivet/master 2/4] lvm_test: refactoring + minor fix

Will Woods wwoods at redhat.com
Tue Sep 23 22:14:01 UTC 2014


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.
---
 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 b7000ea..762ac1b 100755
--- a/tests/devicelibs_test/lvm_test.py
+++ b/tests/devicelibs_test/lvm_test.py
@@ -30,11 +30,11 @@ class LVMTestCase(unittest.TestCase):
 # 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 +57,17 @@ class LVMAsRootTestCase(loopbackedtestcase.LoopBackedTestCase):
         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(LVMAsRootTestCase, self).tearDown()
+        super(LVMAsRootTestCaseBase, self).tearDown()
 
+
+
+class LVMAsRootTestCase(LVMAsRootTestCaseBase):
     def testLVM(self):
         _LOOP_DEV0 = self.loopDevices[0]
         _LOOP_DEV1 = self.loopDevices[1]
@@ -226,6 +229,8 @@ class LVMAsRootTestCase(loopbackedtestcase.LoopBackedTestCase):
         # fail
         self.assertEqual(lvm.lvs(vg_name="wrong-vg-name"), {})
 
+        # TODO: lvorigin, lvsnapshot*, thin*
+
         ##
         ## has_lvm
         ##
-- 
1.9.3



More information about the anaconda-patches mailing list