Commit ae2d667a authored by Serhiy Storchaka's avatar Serhiy Storchaka

Open files in binary mode to avoid newlines transformation.

parents 778db289 c9ba38c2
...@@ -2644,8 +2644,8 @@ Windows line endings first: ...@@ -2644,8 +2644,8 @@ Windows line endings first:
>>> import tempfile, os >>> import tempfile, os
>>> fn = tempfile.mktemp() >>> fn = tempfile.mktemp()
>>> with open(fn, 'w') as f: >>> with open(fn, 'wb') as f:
... f.write('Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n') ... f.write(b'Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n')
35 35
>>> doctest.testfile(fn, False) >>> doctest.testfile(fn, False)
TestResults(failed=0, attempted=1) TestResults(failed=0, attempted=1)
...@@ -2654,8 +2654,8 @@ Windows line endings first: ...@@ -2654,8 +2654,8 @@ Windows line endings first:
And now *nix line endings: And now *nix line endings:
>>> fn = tempfile.mktemp() >>> fn = tempfile.mktemp()
>>> with open(fn, 'w') as f: >>> with open(fn, 'wb') as f:
... f.write('Test:\n\n >>> x = 1 + 1\n\nDone.\n') ... f.write(b'Test:\n\n >>> x = 1 + 1\n\nDone.\n')
30 30
>>> doctest.testfile(fn, False) >>> doctest.testfile(fn, False)
TestResults(failed=0, attempted=1) TestResults(failed=0, attempted=1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment