Running the same test file in both: Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) Python 3.1.1 (r311:74480, Feb 14 2010, 15:55:41) python -m doctest test2.txt and python3 -m doctest test2.txt No failure in 2.6.2. For 3.1.1: File "test2.txt", line 9, in test2.txt Failed example: sys.stdout.write("This text\n contains weird spacing.") # doctest: +NORMALIZE_WHITESPACE Expected: This text contains weird spacing. Got: This text contains weird spacing.38 ********************************************************************** 1 items had failures: 1 of 3 in test2.txt ***Test Failed*** 1 failures.
This doesn't have anything to do with NORMALIZE_WHITESPACE. In python3, .write returns the number of bytes written, instead of None. If you add the 38 to the end of your test line, the test will pass. This is not a bug in doctest, but a difference in 'write' behavior between Python2 and Python3. You can write doctests that will pass on both by explicitly discarding the return value: >>> _ = sys.stdout.write("xxxx"). xxxx
History
Date
User
Action
Args
2022-04-11 14:56:57
admin
set
github: 52229
2013-02-20 03:06:32
r.david.murray
set
status: open -> closednosy: + r.david.murraymessages: + resolution: not a bugstage: resolved