Issue 13337: IGNORE_CASE doctest option flag (original) (raw)
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