From 7a763f1ca474203e07379fe2e71606b01c5b62fb Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 14 Oct 2014 09:40:24 -0500 Subject: testsuite: skip nested exclusive option group test on py2.6 --- src/lib/Bcfg2/Options/OptionGroups.py | 4 ++-- .../Testsrc/Testlib/TestOptions/TestOptionGroups.py | 16 +++++++++++++--- 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"]) -- cgit v1.2.3-1-g7c22