[New-bugs-announce] [issue13337] IGNORE_CASE doctest option flag
Gerald Dalley
report at bugs.python.org
Thu Nov 3 20:03:20 CET 2011
New submission from Gerald Dalley <dalleyg at alum.mit.edu>:
It would be helpful to have a doctest flag that makes the test case insensitive.
Use case: nan values are printed as "nan" with typical Linux implementations, but as "NaN" on other operating systems like Solaris.
In a naive implementation, the core change to doctest.OutputChecker.check_output is:
+ if optionflags & IGNORE_CASE:
+ got = got.lower()
+ want = want.lower()
+ true_line = "true\n"
+ false_line = "false\n"
+ else:
+ true_line = "True\n"
+ false_line = "False\n"
+
# Handle the common case first, for efficiency:
# if they're string-identical, always return true.
if got == want:
return True
# The values True and False replaced 1 and 0 as the return
# value for boolean comparisons in Python 2.3.
if not (optionflags & DONT_ACCEPT_TRUE_FOR_1):
- if (got,want) == ("True\n", "1\n"):
+ if (got,want) == (true_line, "1\n"):
return True
- if (got,want) == ("False\n", "0\n"):
+ if (got,want) == (false_line, "0\n"):
return True
----------
components: Library (Lib)
messages: 146961
nosy: Gerald.Dalley
priority: normal
severity: normal
status: open
title: IGNORE_CASE doctest option flag
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13337>
_______________________________________
More information about the New-bugs-announce
mailing list