[pykickstart 1/3] return parsed object from assert_parse
Brian C. Lane
bcl at redhat.com
Wed Jul 25 16:59:45 UTC 2012
From: "Brian C. Lane" <bcl at redhat.com>
This allows us to create tests that inspect the resulting object instead
of just testing to see if it parses.
---
tests/baseclass.py | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/baseclass.py b/tests/baseclass.py
index 5efd4d2..9d9e8c3 100644
--- a/tests/baseclass.py
+++ b/tests/baseclass.py
@@ -86,21 +86,23 @@ class CommandTest(unittest.TestCase):
# If expectedStr supplied, we want to ensure the parsed result matches
if expectedStr is not None:
- result = parser.parse(args[1:])
+ obj = parser.parse(args[1:])
+ result = str(obj)
# Strip any comment lines ... we only match on non-comments
if ignoreComments:
- result = re.sub("^#[^\n]*\n", "", str(result))
+ result = re.sub("^#[^\n]*\n", "", result)
# Ensure we parsed as expected
- self.assertEqual(str(result), expectedStr)
+ self.assertEqual(result, expectedStr)
# No expectedStr supplied, just make sure it does not raise an
# exception
else:
try:
- result = parser.parse(args[1:])
+ obj = parser.parse(args[1:])
except Exception, e:
self.fail("Failed while parsing: %s" % e)
+ return obj
def assert_parse_error(self, inputStr, exception=KickstartParseError):
'''Assert that parsing the supplied string raises a
--
1.7.7.6
More information about the anaconda-patches
mailing list