[PATCH] Use assertIsInstance in the kickstart version test.

Vratislav Podzimek vpodzime at redhat.com
Fri Sep 27 15:48:27 UTC 2013


On Fri, 2013-09-27 at 11:46 -0400, Chris Lumens wrote:
> This fixes up the case where anaconda doesn't subclass a pykickstart class,
> but still needs to reference one - this case occurs due to initial-setup
> using anaconda.
> ---
>  tests/kickstart_tests/version_test.py | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/kickstart_tests/version_test.py b/tests/kickstart_tests/version_test.py
> index 1e544b8..c3650f8 100644
> --- a/tests/kickstart_tests/version_test.py
> +++ b/tests/kickstart_tests/version_test.py
> @@ -39,18 +39,14 @@ class BaseTestCase(unittest.TestCase):
>  class CommandVersionTestCase(BaseTestCase):
>      def commands_test(self):
>          for (commandName, commandObj) in self._commandMap.iteritems():
> -            baseClass = commandObj().__class__.__bases__[0]
>              pykickstartClass = self.handler.commands[commandName].__class__
> -            self.assertEqual(baseClass.__name__, pykickstartClass.__name__)
> +            self.assertIsInstance(commandObj(), pykickstartClass)
>  
>  # Do the same thing as CommandVersionTestCase, but for data objects.
>  class DataVersionTestCase(BaseTestCase):
>      def data_test(self):
>          for (dataName, dataObj) in self._dataMap.iteritems():
> -            baseClass = dataObj().__class__.__bases__[0]
> -
>              # pykickstart does not expose data objects as a mapping the way
>              # it does command objects.
>              pykickstartClass = eval("self.handler.%s" % dataName)
> -
> -            self.assertEqual(baseClass.__name__, pykickstartClass.__name__)
> +            self.assertIsInstance(dataObj(), pykickstartClass)
Looks good to me.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list