Patchwork [10,of,11,STABLE] tests: open file in binary mode to use POSIX end-of-line style anywhere

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 20, 2014, 1:27 p.m.
Message ID <65e4e7f34d673b223605.1413811624@juju>
Download mbox | patch
Permalink /patch/6424/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Oct. 20, 2014, 1:27 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1413810488 -32400
#      Mon Oct 20 22:08:08 2014 +0900
# Branch stable
# Node ID 65e4e7f34d673b2236058ef9de57ca035a331413
# Parent  0d35f78a9e27433ad6204fe3088d6c400c1d8b89
tests: open file in binary mode to use POSIX end-of-line style anywhere

Before this patch, "test-context.py" fails on Windows environment,
because "diff" output contains unexpected "\r" character.

Opening the target file in text mode causes this automatic end-of-line
conversion.
Matt Mackall - Oct. 21, 2014, 7:14 p.m.
On Mon, 2014-10-20 at 22:27 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1413810488 -32400
> #      Mon Oct 20 22:08:08 2014 +0900
> # Branch stable
> # Node ID 65e4e7f34d673b2236058ef9de57ca035a331413
> # Parent  0d35f78a9e27433ad6204fe3088d6c400c1d8b89
> tests: open file in binary mode to use POSIX end-of-line style anywhere

I've queued 1,3,4,7,8,9, and 10, thanks.

Patch

diff --git a/tests/test-context.py b/tests/test-context.py
--- a/tests/test-context.py
+++ b/tests/test-context.py
@@ -7,7 +7,7 @@  repo = hg.repository(u, 'test1', create=
 os.chdir('test1')
 
 # create 'foo' with fixed time stamp
-f = open('foo', 'w')
+f = open('foo', 'wb')
 f.write('foo\n')
 f.close()
 os.utime('foo', (1000, 1000))