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

Skip to content

Commit c9ba38c

Browse files
Open files in binary mode to avoid newlines transformation.
1 parent 2e229e0 commit c9ba38c

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
@@ -2624,8 +2624,8 @@ def test_lineendings(): r"""
26242624
26252625
>>> import tempfile, os
26262626
>>> fn = tempfile.mktemp()
2627-
>>> with open(fn, 'w') as f:
2628-
... f.write('Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n')
2627+
>>> with open(fn, 'wb') as f:
2628+
... f.write(b'Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n')
26292629
35
26302630
>>> doctest.testfile(fn, False)
26312631
TestResults(failed=0, attempted=1)
@@ -2634,8 +2634,8 @@ def test_lineendings(): r"""
26342634
And now *nix line endings:
26352635
26362636
>>> fn = tempfile.mktemp()
2637-
>>> with open(fn, 'w') as f:
2638-
... f.write('Test:\n\n >>> x = 1 + 1\n\nDone.\n')
2637+
>>> with open(fn, 'wb') as f:
2638+
... f.write(b'Test:\n\n >>> x = 1 + 1\n\nDone.\n')
26392639
30
26402640
>>> doctest.testfile(fn, False)
26412641
TestResults(failed=0, attempted=1)

0 commit comments

Comments
 (0)