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

index 4137d5aa0bfd1b5a504ba6a78225eed09b4f171e..74d512d322101fc468a321e907856269f9f01362 100644 (file)
@@ -2624,8 +2624,8 @@ Windows line endings first:
 
     >>> import tempfile, os
     >>> fn = tempfile.mktemp()
-    >>> with open(fn, 'w') as f:
-    ...    f.write('Test:\r\n\r\n  >>> x = 1 + 1\r\n\r\nDone.\r\n')
+    >>> with open(fn, 'wb') as f:
+    ...    f.write(b'Test:\r\n\r\n  >>> x = 1 + 1\r\n\r\nDone.\r\n')
     35
     >>> doctest.testfile(fn, False)
     TestResults(failed=0, attempted=1)
@@ -2634,8 +2634,8 @@ Windows line endings first:
 And now *nix line endings:
 
     >>> fn = tempfile.mktemp()
-    >>> with open(fn, 'w') as f:
-    ...     f.write('Test:\n\n  >>> x = 1 + 1\n\nDone.\n')
+    >>> with open(fn, 'wb') as f:
+    ...     f.write(b'Test:\n\n  >>> x = 1 + 1\n\nDone.\n')
     30
     >>> doctest.testfile(fn, False)
     TestResults(failed=0, attempted=1)