Skip to content

Commit 528fdd6

Browse files
author
Justin Baum
committed
Add ignore_case flag to doc-test
1 parent 00a6568 commit 528fdd6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Lib/doctest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def _test():
6363
'REPORT_ONLY_FIRST_FAILURE',
6464
'REPORTING_FLAGS',
6565
'FAIL_FAST',
66+
'IGNORE_CASE',
6667
# 1. Utility Functions
6768
# 2. Example & DocTest
6869
'Example',
@@ -139,13 +140,15 @@ def register_optionflag(name):
139140
ELLIPSIS = register_optionflag('ELLIPSIS')
140141
SKIP = register_optionflag('SKIP')
141142
IGNORE_EXCEPTION_DETAIL = register_optionflag('IGNORE_EXCEPTION_DETAIL')
143+
IGNORE_CASE = register_optionflag('IGNORE_CASE')
142144

143145
COMPARISON_FLAGS = (DONT_ACCEPT_TRUE_FOR_1 |
144146
DONT_ACCEPT_BLANKLINE |
145147
NORMALIZE_WHITESPACE |
146148
ELLIPSIS |
147149
SKIP |
148-
IGNORE_EXCEPTION_DETAIL)
150+
IGNORE_EXCEPTION_DETAIL |
151+
IGNORE_CASE)
149152

150153
REPORT_UDIFF = register_optionflag('REPORT_UDIFF')
151154
REPORT_CDIFF = register_optionflag('REPORT_CDIFF')
@@ -1607,6 +1610,12 @@ def check_output(self, want, got, optionflags):
16071610
if got == want:
16081611
return True
16091612

1613+
# Ignore case if flag
1614+
# Lowercase got and want
1615+
if (optionflags & IGNORE_CASE):
1616+
got = got.lower()
1617+
want = want.lower()
1618+
16101619
# The values True and False replaced 1 and 0 as the return
16111620
# value for boolean comparisons in Python 2.3.
16121621
if not (optionflags & DONT_ACCEPT_TRUE_FOR_1):

0 commit comments

Comments
 (0)