Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae2d667

Browse files
Open files in binary mode to avoid newlines transformation.
2 parents 778db28 + c9ba38c commit ae2d667

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Lib/test/test_doctest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,8 +2644,8 @@ def test_lineendings(): r"""
26442644
26452645
>>> import tempfile, os
26462646
>>> fn = tempfile.mktemp()
2647-
>>> with open(fn, 'w') as f:
2648-
... f.write('Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n')
2647+
>>> with open(fn, 'wb') as f:
2648+
... f.write(b'Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n')
26492649
35
26502650
>>> doctest.testfile(fn, False)
26512651
TestResults(failed=0, attempted=1)
@@ -2654,8 +2654,8 @@ def test_lineendings(): r"""
26542654
And now *nix line endings:
26552655
26562656
>>> fn = tempfile.mktemp()
2657-
>>> with open(fn, 'w') as f:
2658-
... f.write('Test:\n\n >>> x = 1 + 1\n\nDone.\n')
2657+
>>> with open(fn, 'wb') as f:
2658+
... f.write(b'Test:\n\n >>> x = 1 + 1\n\nDone.\n')
26592659
30
26602660
>>> doctest.testfile(fn, False)
26612661
TestResults(failed=0, attempted=1)

0 commit comments

Comments
 (0)