[PATCH] Get the unit tests into a runnable state.

Anne Mulhern amulhern at redhat.com
Fri Feb 14 19:46:11 UTC 2014





----- Original Message -----
> From: "David Lehman" <dlehman at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Friday, February 14, 2014 1:42:34 PM
> Subject: [PATCH] Get the unit tests into a runnable state.
> 
> ---
>  tests/action_test.py    | 2 +-
>  tests/clearpart_test.py | 7 +++++++
>  tests/udev_test.py      | 9 ++++++++-
>  3 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/action_test.py b/tests/action_test.py
> index 06d21de..bc906c9 100644
> --- a/tests/action_test.py
> +++ b/tests/action_test.py
> @@ -27,7 +27,7 @@ from blivet.deviceaction import ActionResizeFormat
>  from blivet.deviceaction import ActionDestroyFormat
>  
>  """ DeviceActionTestSuite """
> -
> + at unittest.skip("broken")
>  class DeviceActionTestCase(StorageTestCase):
>      def setUp(self):
>          """ Create something like a preexisting autopart on two disks
>          (sda,sdb).

In RHEL7 a chunk of line 'class DeviceActionTestCase....' is missing and will need to be restored.
I guess that's the SyntaxError that causes the ImportError.

Otherwise, ack.

> diff --git a/tests/clearpart_test.py b/tests/clearpart_test.py
> index 97dda24..1486bde 100644
> --- a/tests/clearpart_test.py
> +++ b/tests/clearpart_test.py
> @@ -4,8 +4,12 @@ import mock
>  import blivet
>  from pykickstart.constants import *
>  from parted import PARTITION_NORMAL
> +from blivet.flags import flags
>  
>  class ClearPartTestCase(unittest.TestCase):
> +    def setUp(self):
> +        flags.testing = True
> +
>      def testShouldClear(self):
>          """ Test the Blivet.shouldClear method. """
>          b = blivet.Blivet()
> @@ -181,6 +185,9 @@ class ClearPartTestCase(unittest.TestCase):
>          #
>          # TODO
>  
> +    def tearDown(self):
> +        flags.testing = False
> +
>      def testInitializeDisk(self):
>          """
>              magic partitions

There is no clearpart test case in RHEL7, but this looks good to me for master.

> 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.5.3
> 

This one looks good wrt. master but I think you need to cherry-pick a whole commit from master into the RHEL7 branch and put this on top of it.

- mulhern


More information about the anaconda-patches mailing list