Blob Blame History Raw
From c10698daec30cb65243ccc2a5b7c9979c83b6f9e Mon Sep 17 00:00:00 2001
From: Chris Lumens <clumens@redhat.com>
Date: Fri, 4 Mar 2016 14:30:16 -0500
Subject: [PATCH] Make sure the script test references parser.

What I was seeing was that the test failed because the script strings
didn't have a %end on them.  That means the version was being set to
something pre-F8.  It only happened if any of the pre* or post* tests
were run first - if those were moved out of the way, the script test
would pass.  These tests were therefore the ones causing the version to
be set incorrectly.

What's happening is those tests set the version to something old, but
nothing sets the version back.  That's because Script references a
global ver variable which is set when a parser is created.  The Script
test doesn't create a parser so ver was staying set to whatever old
value pre* and post* were setting.

(cherry picked from commit 5c33825407035f33bfd8ae257ec093c10937b81c)
---
 tests/script.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/script.py b/tests/script.py
index bad9b81..7ef1002 100644
--- a/tests/script.py
+++ b/tests/script.py
@@ -1,12 +1,19 @@
 import unittest
 
-from tests.baseclass import CommandTest
+from tests.baseclass import ParserTest
 
 from pykickstart.constants import KS_SCRIPT_POST, KS_SCRIPT_PRE, KS_SCRIPT_PREINSTALL, KS_SCRIPT_TRACEBACK, KS_SCRIPT_ONERROR
 from pykickstart.parser import Script
+from pykickstart.version import DEVEL
 
-class Script_Object_TestCase(CommandTest):
+class Script_Object_TestCase(ParserTest):
     def runTest(self):
+        # The parser object will never be set up by this test, which means the
+        # Script object will get the version number of whatever ran last.  That
+        # could be totally wrong.  Thus, cause the parser to be created here
+        # so the version will be right.
+        self.get_parser()
+
         body = "import sys\nsys.exit(1)\n"
         obj = Script(body, type=KS_SCRIPT_PRE, interp="/usr/bin/python", logfile="/tmp/log", errorOnFail=True)
         self.assertEqual(obj.type, KS_SCRIPT_PRE)
-- 
2.17.1