Variant of patch #1478292. doctest.register_optionflag(name)

shouldn't create a new flag when `name` is already the name of
an option flag.
This commit is contained in:
Tim Peters 2006-05-10 02:43:01 +00:00
parent 40f55b2f08
commit ad2ef33245
3 changed files with 26 additions and 4 deletions

View file

@ -1300,6 +1300,26 @@ count as failures:
ValueError: 2
(3, 5)
New option flags can also be registered, via register_optionflag(). Here
we reach into doctest's internals a bit.
>>> unlikely = "UNLIKELY_OPTION_NAME"
>>> unlikely in doctest.OPTIONFLAGS_BY_NAME
False
>>> new_flag_value = doctest.register_optionflag(unlikely)
>>> unlikely in doctest.OPTIONFLAGS_BY_NAME
True
Before 2.4.4/2.5, registering a name more than once erroneously created
more than one flag value. Here we verify that's fixed:
>>> redundant_flag_value = doctest.register_optionflag(unlikely)
>>> redundant_flag_value == new_flag_value
True
Clean up.
>>> del doctest.OPTIONFLAGS_BY_NAME[unlikely]
"""
def option_directives(): r"""