summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2014-10-14 09:40:24 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2014-10-22 13:11:55 -0500
commit7a763f1ca474203e07379fe2e71606b01c5b62fb (patch)
treee647c31df9a40f4d3b3942aed2f6ed05d5317e2d
parent5c0b8c2b0229992671e076e74c1256a880381d62 (diff)
downloadbcfg2-7a763f1ca474203e07379fe2e71606b01c5b62fb.tar.gz
bcfg2-7a763f1ca474203e07379fe2e71606b01c5b62fb.tar.bz2
bcfg2-7a763f1ca474203e07379fe2e71606b01c5b62fb.zip
testsuite: skip nested exclusive option group test on py2.6
-rw-r--r--src/lib/Bcfg2/Options/OptionGroups.py4
-rw-r--r--testsuite/Testsrc/Testlib/TestOptions/TestOptionGroups.py16
2 files changed, 15 insertions, 5 deletions
diff --git a/src/lib/Bcfg2/Options/OptionGroups.py b/src/lib/Bcfg2/Options/OptionGroups.py
index 426ee5dc0..49340ab36 100644
--- a/src/lib/Bcfg2/Options/OptionGroups.py
+++ b/src/lib/Bcfg2/Options/OptionGroups.py
@@ -70,8 +70,8 @@ class ExclusiveOptionGroup(_OptionContainer):
self.required = kwargs.pop('required', False)
def add_to_parser(self, parser):
- group = parser.add_mutually_exclusive_group(required=self.required)
- _OptionContainer.add_to_parser(self, group)
+ _OptionContainer.add_to_parser(
+ self, parser.add_mutually_exclusive_group(required=self.required))
class Subparser(_OptionContainer):
diff --git a/testsuite/Testsrc/Testlib/TestOptions/TestOptionGroups.py b/testsuite/Testsrc/Testlib/TestOptions/TestOptionGroups.py
index de1abbb1b..7611d6202 100644
--- a/testsuite/Testsrc/Testlib/TestOptions/TestOptionGroups.py
+++ b/testsuite/Testsrc/Testlib/TestOptions/TestOptionGroups.py
@@ -1,11 +1,12 @@
"""test reading multiple config files."""
import argparse
+import sys
from Bcfg2.Options import Option, BooleanOption, Parser, OptionGroup, \
ExclusiveOptionGroup, WildcardSectionGroup, new_parser, get_parser
-from testsuite.common import Bcfg2TestCase
+from testsuite.common import Bcfg2TestCase, skipUnless
from testsuite.Testsrc.Testlib.TestOptions import make_config, OptionTestCase
@@ -59,8 +60,10 @@ class TestOptionGroups(Bcfg2TestCase):
self.assertRaises(SystemExit, self._test_options, [])
- def test_option_group(self):
- """nest option groups."""
+
+class TestNestedOptionGroups(TestOptionGroups):
+ def setUp(self):
+ TestOptionGroups.setUp(self)
self.options = [
OptionGroup(
BooleanOption("--foo"),
@@ -73,6 +76,9 @@ class TestOptionGroups(Bcfg2TestCase):
BooleanOption("--test2")),
title="inner"),
title="outer")]
+
+ def test_option_group(self):
+ """nest option groups."""
result = self._test_options(["--foo", "--baz", "--test1"])
self.assertTrue(result.foo)
self.assertFalse(result.bar)
@@ -81,6 +87,10 @@ class TestOptionGroups(Bcfg2TestCase):
self.assertTrue(result.test1)
self.assertFalse(result.test2)
+ @skipUnless(sys.version_info >= (2, 7),
+ "Nested exclusive option groups do not work in Python 2.6")
+ def test_nested_exclusive_option_groups(self):
+ """nest exclusive option groups."""
self.assertRaises(SystemExit,
self._test_options, ["--test1", "--test2"])