2 from tests
.baseclass
import *
4 from pykickstart
import constants
5 from pykickstart
.errors
import KickstartParseError
6 from pykickstart
.version
import RHEL6
8 class Packages_Contains_Comments_TestCase(ParserTest
):
11 packageA # this is an end-of-line comment
12 # this is a whole line comment
18 self
.parser
.readKickstartFromString(self
.ks
)
20 # Verify that the packages are what we think they are.
21 self
.assertEqual(len(self
.handler
.packages
.packageList
), 2)
22 self
.assertEqual(self
.handler
.packages
.packageList
[0], "packageA")
23 self
.assertEqual(self
.handler
.packages
.packageList
[1], "packageB")
25 class Packages_Contains_Nobase_1_TestCase(ParserTest
):
33 with warnings
.catch_warnings(record
=True) as w
:
34 warnings
.simplefilter("always")
35 self
.parser
.readKickstartFromString(self
.ks
)
36 self
.assertEqual(len(w
), 1)
37 self
.assertIsInstance(w
[-1].message
, DeprecationWarning)
39 class Packages_Contains_Nobase_2_TestCase(ParserTest
):
49 with warnings
.catch_warnings(record
=True) as w
:
50 warnings
.simplefilter("always")
51 self
.parser
.readKickstartFromString(self
.ks
)
52 self
.assertEqual(len(w
), 0)
54 class Packages_Contains_Nobase_Default_TestCase(ParserTest
):
56 %packages --nobase --default
61 with warnings
.catch_warnings(record
=True) as w
:
62 warnings
.simplefilter("always")
63 self
.assertRaises(KickstartParseError
, self
.parser
.readKickstartFromString
, self
.ks
)
65 class Packages_Contains_Nocore_Default_TestCase(ParserTest
):
67 %packages --nocore --default
72 with warnings
.catch_warnings(record
=True) as w
:
73 warnings
.simplefilter("always")
74 self
.assertRaises(KickstartParseError
, self
.parser
.readKickstartFromString
, self
.ks
)
76 class Packages_Contains_Environment_1_TestCase(ParserTest
):
79 @^whatever-environment
84 with warnings
.catch_warnings(record
=True) as w
:
85 warnings
.simplefilter("always")
86 self
.parser
.readKickstartFromString(self
.ks
)
87 self
.assertEqual(self
.handler
.packages
.environment
, "whatever-environment")
89 class Packages_Contains_Environment_2_TestCase(ParserTest
):
92 @^whatever-environment
98 with warnings
.catch_warnings(record
=True) as w
:
99 warnings
.simplefilter("always")
100 self
.parser
.readKickstartFromString(self
.ks
)
101 self
.assertEqual(self
.handler
.packages
.environment
, "another-environment")
103 class Packages_Contains_Environment_3_TestCase(ParserTest
):
106 @^whatever-environment
107 -@^another-environment
112 with warnings
.catch_warnings(record
=True) as w
:
113 warnings
.simplefilter("always")
114 self
.parser
.readKickstartFromString(self
.ks
)
115 self
.assertEqual(self
.handler
.packages
.environment
, "whatever-environment")
117 class Packages_Contains_Environment_4_TestCase(ParserTest
):
120 @^whatever-environment
121 -@^whatever-environment
122 @^another-environment
127 with warnings
.catch_warnings(record
=True) as w
:
128 warnings
.simplefilter("always")
129 self
.parser
.readKickstartFromString(self
.ks
)
130 self
.assertEqual(self
.handler
.packages
.environment
, "another-environment")
132 if __name__
== "__main__":