diff options
author | Edward Loper <edloper@gradient.cis.upenn.edu> | 2004-08-12 02:02:24 (GMT) |
---|---|---|
committer | Edward Loper <edloper@gradient.cis.upenn.edu> | 2004-08-12 02:02:24 (GMT) |
commit | ac20f57c2810ad980953d6d8f65fb6f3e2c6c741 (patch) | |
tree | 42f3b17f95085a1a43053db346d222d8ae137e70 /Lib | |
parent | 568671fc0fbcb70d5ba09c7211afff4f9d0d09e1 (diff) | |
download | cpython-ac20f57c2810ad980953d6d8f65fb6f3e2c6c741.zip cpython-ac20f57c2810ad980953d6d8f65fb6f3e2c6c741.tar.gz cpython-ac20f57c2810ad980953d6d8f65fb6f3e2c6c741.tar.bz2 |
- Added a register_optionflag function (so users can add their own
option flags); and use it to define the existing optionflag
constants.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/doctest.py | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index 7c07131..31c0af8 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -193,28 +193,6 @@ from StringIO import StringIO real_pdb_set_trace = pdb.set_trace -# Option constants. -DONT_ACCEPT_TRUE_FOR_1 = 1 << 0 -DONT_ACCEPT_BLANKLINE = 1 << 1 -NORMALIZE_WHITESPACE = 1 << 2 -ELLIPSIS = 1 << 3 -UNIFIED_DIFF = 1 << 4 -CONTEXT_DIFF = 1 << 5 - -OPTIONFLAGS_BY_NAME = { - 'DONT_ACCEPT_TRUE_FOR_1': DONT_ACCEPT_TRUE_FOR_1, - 'DONT_ACCEPT_BLANKLINE': DONT_ACCEPT_BLANKLINE, - 'NORMALIZE_WHITESPACE': NORMALIZE_WHITESPACE, - 'ELLIPSIS': ELLIPSIS, - 'UNIFIED_DIFF': UNIFIED_DIFF, - 'CONTEXT_DIFF': CONTEXT_DIFF, - } - -# Special string markers for use in `want` strings: -BLANKLINE_MARKER = '<BLANKLINE>' -ELLIPSIS_MARKER = '...' - - # There are 4 basic classes: # - Example: a <source, want> pair, plus an intra-docstring line number. # - DocTest: a collection of examples, parsed from a docstring, plus @@ -234,6 +212,24 @@ ELLIPSIS_MARKER = '...' # | Example | # +---------+ +# Option constants. +OPTIONFLAGS_BY_NAME = {} +def register_optionflag(name): + flag = 1 << len(OPTIONFLAGS_BY_NAME) + OPTIONFLAGS_BY_NAME[name] = flag + return flag + +DONT_ACCEPT_TRUE_FOR_1 = register_optionflag('DONT_ACCEPT_TRUE_FOR_1') +DONT_ACCEPT_BLANKLINE = register_optionflag('DONT_ACCEPT_BLANKLINE') +NORMALIZE_WHITESPACE = register_optionflag('NORMALIZE_WHITESPACE') +ELLIPSIS = register_optionflag('ELLIPSIS') +UNIFIED_DIFF = register_optionflag('UNIFIED_DIFF') +CONTEXT_DIFF = register_optionflag('CONTEXT_DIFF') + +# Special string markers for use in `want` strings: +BLANKLINE_MARKER = '<BLANKLINE>' +ELLIPSIS_MARKER = '...' + ###################################################################### ## Table of Contents ###################################################################### |