[PATCH] Run the pykickstart version test on the commands in parse-dracut
David Shea
dshea at redhat.com
Mon Mar 24 21:04:17 UTC 2014
(this one doesn't leave behind dracut/parse-kickstartc)
---
tests/kickstart_tests/version_test.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/tests/kickstart_tests/version_test.py b/tests/kickstart_tests/version_test.py
index c3650f8..b77cb26 100644
--- a/tests/kickstart_tests/version_test.py
+++ b/tests/kickstart_tests/version_test.py
@@ -18,6 +18,7 @@
# Author: Chris Lumens <clumens at redhat.com>
from mock import Mock
import unittest
+import os
class BaseTestCase(unittest.TestCase):
def setUp(self):
@@ -50,3 +51,27 @@ class DataVersionTestCase(BaseTestCase):
# it does command objects.
pykickstartClass = eval("self.handler.%s" % dataName)
self.assertIsInstance(dataObj(), pykickstartClass)
+
+# Copy the commands tests but with the command map from dracut/parse-kickstart
+class DracutCommandVersionTestCase(CommandVersionTestCase):
+ def setUp(self):
+ CommandVersionTestCase.setUp(self)
+
+ # top_srcdir should have been set by nosetests.sh. If it wasn't, the KeyError
+ # will fail the test.
+ parse_kickstart_path = os.path.join(os.environ['top_srcdir'], 'dracut', 'parse-kickstart')
+
+ import tempfile
+ with tempfile.NamedTemporaryFile() as parse_temp:
+ # Compile the file manually to a tempfile so that the import doesn't automatically
+ # crud up the source directory with parse-kickstartc
+ import py_compile
+ parse_temp = tempfile.NamedTemporaryFile()
+ py_compile.compile(parse_kickstart_path, parse_temp.name)
+
+ # Use imp to pretend that hyphens are ok for module names
+ import imp
+ parse_module = imp.load_module('parse_kickstart', parse_temp.file,
+ parse_temp.name, ('', 'r', imp.PY_COMPILED))
+
+ self._commandMap = parse_module.dracutCmds
--
1.9.0
More information about the anaconda-patches
mailing list