]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Open files in binary mode to avoid newlines transformation.
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 4 Apr 2015 07:36:15 +0000 (10:36 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 4 Apr 2015 07:36:15 +0000 (10:36 +0300)
Lib/test/test_doctest.py

index 61c7ba74988f99b1734c91117c5fb79306678022..c1e4c139e706fe622cdc85538f5c78d0fef80e00 100644 (file)
@@ -2580,7 +2580,7 @@ Windows line endings first:
 
     >>> import tempfile, os
     >>> 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')
     >>> doctest.testfile(fn, False)
     TestResults(failed=0, attempted=1)
@@ -2589,7 +2589,7 @@ Windows line endings first:
 And now *nix line endings:
 
     >>> 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')
     >>> doctest.testfile(fn, False)
     TestResults(failed=0, attempted=1)