This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: doctest fails if you have inconsistent lineendings
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, lregebro, python-dev, r.david.murray, terry.reedy
Priority: normal Keywords: patch

Created on 2010-04-20 16:40 by lregebro, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
doctest_lineendings.patch lregebro, 2010-04-20 16:40
Messages (7)
msg103735 - (view) Author: Lennart Regebro (lregebro) Date: 2010-04-20 16:40
If the doctest file has both Windows and unix lineendings you get an error. Yeah, I know, it's not a serious bug, but it's also easy to fix.

Attached patch with test. Seems to not be an issue on Python 3.
msg106737 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-05-29 20:38
Looks good to me. Is there’s no disagreement on this being a bug fix rather than a new feature, it could go before the rc.
msg112905 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-04 21:48
I would call this a bug and still 2.7 eligible. The patch amounts to opening the file to be tested in universal newline mode + a corresponding test. If Python will run files with mixed line endings, doctest should test them.
msg148279 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-11-24 16:41
The string in the test does not have mixed line endings, and the accompanying comment talks about testing files with CRLF on Unix.

Terry, do you want to (update and) commit this?
msg151211 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-01-14 01:29
By 'update', do you mean to change

+Due to the way releases are made on different platforms, we sometimes test
+files on a *nix system with Windows file endings. Unfortunately, that leaves
+some of the test files broken:

to something like

+Issue8473: Make sure doctest works with mixed line endings.
+When this test is run on *nix, it has the side effect of making sure
+that doctest can handle Windows line endings on *nix.

Or just leave the last two lines off?

And also change '/r/n/r/n' x 2 to '/r/n/n' and '/n/r/n'.
msg228296 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-10-03 02:44
New changeset 4a5f79ca8ef0 by R David Murray in branch '2.7':
#8473: make doctest.testfile use universal newline mode.
https://hg.python.org/cpython/rev/4a5f79ca8ef0

New changeset e6050cd9e29e by R David Murray in branch '3.4':
#8473: Add tests that doctest uses universal newlines in testfile.
https://hg.python.org/cpython/rev/e6050cd9e29e

New changeset 7d587fbd7d09 by R David Murray in branch 'default':
Merge: #8473: Add tests that doctest uses universal newlines in testfile.
https://hg.python.org/cpython/rev/7d587fbd7d09
msg228298 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-10-03 02:45
I changed the test text to talk only about universal newline mode, since that is what it is testing.  Someone could add a test for actual mixed line endings to it if they like.
History
Date User Action Args
2022-04-11 14:57:00adminsetgithub: 52719
2014-10-03 02:45:43r.david.murraysetstatus: open -> closed

type: behavior

nosy: + r.david.murray
messages: + msg228298
resolution: fixed
stage: commit review -> resolved
2014-10-03 02:44:37python-devsetnosy: + python-dev
messages: + msg228296
2012-01-14 01:29:47terry.reedysetmessages: + msg151211
2011-11-24 16:41:30eric.araujosetmessages: + msg148279
2010-08-04 21:48:02terry.reedysetversions: - Python 2.6, Python 2.5
nosy: + terry.reedy

messages: + msg112905

stage: commit review
2010-05-29 20:38:54eric.araujosetpriority: normal
2010-05-29 20:38:27eric.araujosetpriority: normal -> (no value)

nosy: + eric.araujo
messages: + msg106737

components: + Library (Lib), - Extension Modules, Tests
2010-04-20 16:40:16lregebrocreate