[blivet:rhel7 3/6] Skip a test if device isn't available (#1065431)

mulhern amulhern at redhat.com
Mon Feb 17 22:08:22 UTC 2014


Related: rhbz#1065431

Cherry-picked from commit 3e51ef5940d54b5dd8e66da20e7fa345cf694062
(udev_test.py part) on master.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 tests/udev_test.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tests/udev_test.py b/tests/udev_test.py
index feaca45..4bac44f 100644
--- a/tests/udev_test.py
+++ b/tests/udev_test.py
@@ -104,6 +104,9 @@ class UdevTest(unittest.TestCase):
         import blivet.udev
         # For this one we're accessing the real uevent file (twice).
         path = '/devices/virtual/block/loop1'
+        if not os.path.exists("/sys" + path):
+            self.skipTest("this test requires the presence of /dev/loop1")
+
         info = {'sysfs_path': path}
         for line in open('/sys' + path + '/uevent').readlines():
             (name, equals, value) = line.strip().partition("=")
@@ -126,8 +129,12 @@ class UdevTest(unittest.TestCase):
         import blivet.udev
         blivet.udev.os.path.normpath = os.path.normpath
         blivet.udev.os.access.return_value = False
+        path = '/devices/virtual/block/loop1'
+        if not os.path.exists("/sys" + path):
+            self.skipTest("this test requires the presence of /dev/loop1")
+
+        dev = {'sysfs_path': path}
 
-        dev = {'sysfs_path': '/devices/virtual/block/loop1'}
         ret = blivet.udev.udev_parse_uevent_file(dev)
         self.assertEqual(ret, {'sysfs_path': '/devices/virtual/block/loop1'})
 
-- 
1.8.3.1



More information about the anaconda-patches mailing list