[master 18/22] Don't use utilsAvailable to skip tests.

mulkieran installerbot-noreply at redhat.com
Tue May 5 16:35:42 UTC 2015


From: mulhern <amulhern at redhat.com>

Related: #12

Use the methods that check the availability of the specific tasks required.
With the additional granularity can test a bunch more things.

Note that it is not possible to use resizable to check availability of test.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 tests/formats_test/fslabeling.py | 18 +++++++++++--
 tests/formats_test/fstesting.py  | 55 +++++++++++++++++++++++++---------------
 2 files changed, 51 insertions(+), 22 deletions(-)

diff --git a/tests/formats_test/fslabeling.py b/tests/formats_test/fslabeling.py
index 4c76265..200cffe 100644
--- a/tests/formats_test/fslabeling.py
+++ b/tests/formats_test/fslabeling.py
@@ -26,8 +26,10 @@ def __init__(self, methodName='runTest'):
 
     def setUp(self):
         an_fs = self._fs_class()
-        if not an_fs.utilsAvailable:
-            self.skipTest("utilities unavailable for filesystem %s" % an_fs.name)
+        if not an_fs.formattable:
+            self.skipTest("can not create filesystem %s" % an_fs.name)
+        if not an_fs.labeling():
+            self.skipTest("can not label filesystem %s" % an_fs.name)
         super(LabelingAsRoot, self).setUp()
 
     def testLabeling(self):
@@ -38,6 +40,8 @@ def testLabeling(self):
            * raise an exception when relabeling the filesystem
         """
         an_fs = self._fs_class(device=self.loopDevices[0], label=self._invalid_label)
+        if an_fs._readlabel.availabilityErrors or not an_fs.relabels():
+            self.skipTest("can not read or write label for filesystem %s" % an_fs.name)
         self.assertIsNone(an_fs.create())
 
         with self.assertRaises(FSReadLabelError):
@@ -79,6 +83,8 @@ def testLabeling(self):
            * raise an exception when relabeling with an invalid label
         """
         an_fs = self._fs_class(device=self.loopDevices[0], label=self._invalid_label)
+        if an_fs._readlabel.availabilityErrors or not an_fs.relabels():
+            self.skipTest("can not read or write label for filesystem %s" % an_fs.name)
         self.assertIsNone(an_fs.create())
 
         with self.assertRaises(FSReadLabelError):
@@ -116,6 +122,8 @@ def testLabeling(self):
            * raise an exception when relabeling with an invalid label
         """
         an_fs = self._fs_class(device=self.loopDevices[0], label=self._invalid_label)
+        if an_fs._readlabel.availabilityErrors or not an_fs.relabels():
+            self.skipTest("can not read or write label for filesystem %s" % an_fs.name)
         self.assertIsNone(an_fs.create())
         self.assertEqual(an_fs.readLabel(), an_fs._labelfs.default_label)
 
@@ -140,6 +148,8 @@ def testCreating(self):
            Verify that the filesystem has that label.
         """
         an_fs = self._fs_class(device=self.loopDevices[0], label="start")
+        if an_fs._readlabel.availabilityErrors:
+            self.skipTest("can not read label for filesystem %s" % an_fs.name)
         self.assertIsNone(an_fs.create())
         self.assertEqual(an_fs.readLabel(), "start")
 
@@ -148,6 +158,8 @@ def testCreatingNone(self):
            Verify that the filesystem has the default label.
         """
         an_fs = self._fs_class(device=self.loopDevices[0], label=None)
+        if an_fs._readlabel.availabilityErrors:
+            self.skipTest("can not read label for filesystem %s" % an_fs.name)
         self.assertIsNone(an_fs.create())
         self.assertEqual(an_fs.readLabel(), an_fs._labelfs.default_label)
 
@@ -156,5 +168,7 @@ def testCreatingEmpty(self):
            Verify that the filesystem has the empty label.
         """
         an_fs = self._fs_class(device=self.loopDevices[0], label="")
+        if an_fs._readlabel.availabilityErrors:
+            self.skipTest("can not read label for filesystem %s" % an_fs.name)
         self.assertIsNone(an_fs.create())
         self.assertEqual(an_fs.readLabel(), "")
diff --git a/tests/formats_test/fstesting.py b/tests/formats_test/fstesting.py
index 59f8100..b8c4944 100644
--- a/tests/formats_test/fstesting.py
+++ b/tests/formats_test/fstesting.py
@@ -26,9 +26,6 @@ def __init__(self, methodName='runTest'):
         super(FSAsRoot, self).__init__(methodName=methodName, deviceSpec=[self._DEVICE_SIZE])
 
     def setUp(self):
-        an_fs = self._fs_class()
-        if not an_fs.utilsAvailable:
-            self.skipTest("utilities unavailable for filesystem %s" % an_fs.name)
         super(FSAsRoot, self).setUp()
 
     def _test_sizes(self, an_fs):
@@ -112,7 +109,7 @@ def testInstantiation(self):
     def testCreation(self):
         an_fs = self._fs_class()
         if not an_fs.formattable:
-            return
+            self.skipTest("can not create filesystem %s" % an_fs.name)
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         self.assertEqual(an_fs.resizable, False)
@@ -130,8 +127,8 @@ def testCreation(self):
 
     def testLabeling(self):
         an_fs = self._fs_class()
-        if not an_fs.labeling():
-            return
+        if not an_fs.formattable or not an_fs.labeling():
+            self.skipTest("can not label filesystem %s" % an_fs.name)
         an_fs.device = self.loopDevices[0]
         an_fs.label = "label"
         self.assertTrue(an_fs.labelFormatOK("label"))
@@ -144,8 +141,8 @@ def testLabeling(self):
 
     def testRelabeling(self):
         an_fs = self._fs_class()
-        if not an_fs.labeling():
-            return
+        if not an_fs.formattable or not an_fs.labeling():
+            self.skipTest("can not label filesystem %s" % an_fs.name)
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         an_fs.label = "label"
@@ -160,9 +157,9 @@ def testMounting(self):
         an_fs = self._fs_class()
         # FIXME: BTRFS fails to mount
         if isinstance(an_fs, fs.BTRFS):
-            return
+            self.skipTest("no mounting filesystem %s" % an_fs.name)
         if not an_fs.formattable:
-            return
+            self.skipTest("can not create filesystem %s" % an_fs.name)
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         self.assertTrue(an_fs.testMount())
@@ -171,9 +168,9 @@ def testMountpoint(self):
         an_fs = self._fs_class()
         # FIXME: BTRFS fails to mount
         if isinstance(an_fs, fs.BTRFS):
-            return
+            self.skipTest("no mounting filesystem %s" % an_fs.name)
         if not an_fs.formattable or not an_fs.mountable:
-            return
+            self.skipTest("can not create or mount filesystem %s" % an_fs.name)
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         mountpoint = tempfile.mkdtemp()
@@ -185,8 +182,8 @@ def testMountpoint(self):
 
     def testResize(self):
         an_fs = self._fs_class()
-        if not an_fs.formattable or not an_fs.resizable:
-            return
+        if not an_fs.formattable:
+            self.skipTest("can not create filesystem %s" % an_fs.name)
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         an_fs.updateSizeInfo()
@@ -225,9 +222,12 @@ def testNoExplicitTargetSize(self):
         # gets value of _size in constructor, so if _size is set to not-zero
         # in constructor call behavior would be different.
         if not self._resizable:
-            return
+            self.skipTest("Not checking resize for this test category.")
 
         an_fs = self._fs_class()
+        if not an_fs.formattable:
+            self.skipTest("can not create filesystem %s" % an_fs.name)
+
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         an_fs.updateSizeInfo()
@@ -245,10 +245,13 @@ def testNoExplicitTargetSize2(self):
             resize action resizes filesystem to that size.
         """
         if not self._resizable:
-            return
+            self.skipTest("Not checking resize for this test category.")
 
         SIZE = Size("64 MiB")
         an_fs = self._fs_class(size=SIZE)
+        if not an_fs.formattable:
+            self.skipTest("can not create filesystem %s" % an_fs.name)
+
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         an_fs.updateSizeInfo()
@@ -264,9 +267,12 @@ def testNoExplicitTargetSize2(self):
 
     def testShrink(self):
         if not self._resizable:
-            return
+            self.skipTest("Not checking resize for this test category.")
 
         an_fs = self._fs_class()
+        if not an_fs.formattable:
+            self.skipTest("can not create filesystem %s" % an_fs.name)
+
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         an_fs.updateSizeInfo()
@@ -294,9 +300,12 @@ def testShrink(self):
 
     def testTooSmall(self):
         if not self._resizable:
-            return
+            self.skipTest("Not checking resize for this test category.")
 
         an_fs = self._fs_class()
+        if not an_fs.formattable:
+            self.skipTest("can not create or resize filesystem %s" % an_fs.name)
+
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         an_fs.updateSizeInfo()
@@ -311,9 +320,12 @@ def testTooSmall(self):
 
     def testTooBig(self):
         if not self._resizable:
-            return
+            self.skipTest("Not checking resize for this test category.")
 
         an_fs = self._fs_class()
+        if not an_fs.formattable:
+            self.skipTest("can not create filesystem %s" % an_fs.name)
+
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         an_fs.updateSizeInfo()
@@ -328,9 +340,12 @@ def testTooBig(self):
 
     def testTooBig2(self):
         if not self._resizable:
-            return
+            self.skipTest("Not checking resize for this test category.")
 
         an_fs = self._fs_class()
+        if not an_fs.formattable:
+            self.skipTest("can not create filesystem %s" % an_fs.name)
+
         an_fs.device = self.loopDevices[0]
         self.assertIsNone(an_fs.create())
         an_fs.updateSizeInfo()


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


More information about the anaconda-patches mailing list