diff --git a/py/test/parseopt.py b/py/test/parseopt.py index ba4f4f0ad..8a660849b 100644 --- a/py/test/parseopt.py +++ b/py/test/parseopt.py @@ -38,11 +38,11 @@ class Parser: self._groups.append(group) return group - def getgroup(self, name): + def getgroup(self, name, description=""): for group in self._groups: if group.name == name: return group - raise ValueError("group %r not found" %(name,)) + return self.addgroup(name, description) def addoption(self, *opts, **attrs): """ add an optparse-style option. """ diff --git a/py/test/testing/test_parseopt.py b/py/test/testing/test_parseopt.py index 7db00e7c6..756fe0523 100644 --- a/py/test/testing/test_parseopt.py +++ b/py/test/testing/test_parseopt.py @@ -18,7 +18,15 @@ class TestParser: py.test.raises(ValueError, parser.addgroup, "hello") group2 = parser.getgroup("hello") assert group2 is group - py.test.raises(ValueError, parser.getgroup, 'something') + + def test_getgroup_addsgroup(self): + parser = parseopt.Parser() + group = parser.getgroup("hello", description="desc") + assert group.name == "hello" + assert group.description == "desc" + group2 = parser.getgroup("hello") + assert group2 is group + def test_group_addoption(self): group = parseopt.OptionGroup("hello")