Patchwork D2125: py3: replace file() with open() in test-import-eol.t

login
register
mail settings
Submitter phabricator
Date Feb. 11, 2018, 2:05 p.m.
Message ID <b2f2b04ad580232e477a6077f37600cb@localhost.localdomain>
Download mbox | patch
Permalink /patch/27566/
State Not Applicable
Headers show

Comments

phabricator - Feb. 11, 2018, 2:05 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa4d7e51709e5: py3: replace file() with open() in test-import-eol.t (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2125?vs=5388&id=5414

REVISION DETAIL
  https://phab.mercurial-scm.org/D2125

AFFECTED FILES
  tests/test-import-eol.t

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-import-eol.t b/tests/test-import-eol.t
--- a/tests/test-import-eol.t
+++ b/tests/test-import-eol.t
@@ -1,21 +1,21 @@ 
   $ cat > makepatch.py <<EOF
-  > f = file('eol.diff', 'wb')
+  > f = open('eol.diff', 'wb')
   > w = f.write
-  > w('test message\n')
-  > w('diff --git a/a b/a\n')
-  > w('--- a/a\n')
-  > w('+++ b/a\n')
-  > w('@@ -1,5 +1,5 @@\n')
-  > w(' a\n')
-  > w('-bbb\r\n')
-  > w('+yyyy\r\n')
-  > w(' cc\r\n')
-  > w(' \n')
-  > w(' d\n')
-  > w('-e\n')
-  > w('\ No newline at end of file\n')
-  > w('+z\r\n')
-  > w('\ No newline at end of file\r\n')
+  > w(b'test message\n')
+  > w(b'diff --git a/a b/a\n')
+  > w(b'--- a/a\n')
+  > w(b'+++ b/a\n')
+  > w(b'@@ -1,5 +1,5 @@\n')
+  > w(b' a\n')
+  > w(b'-bbb\r\n')
+  > w(b'+yyyy\r\n')
+  > w(b' cc\r\n')
+  > w(b' \n')
+  > w(b' d\n')
+  > w(b'-e\n')
+  > w(b'\ No newline at end of file\n')
+  > w(b'+z\r\n')
+  > w(b'\ No newline at end of file\r\n')
   > EOF
 
   $ hg init repo
@@ -25,7 +25,7 @@ 
 
 Test different --eol values
 
-  $ $PYTHON -c 'file("a", "wb").write("a\nbbb\ncc\n\nd\ne")'
+  $ $PYTHON -c 'open("a", "wb").write(b"a\nbbb\ncc\n\nd\ne")'
   $ hg ci -Am adda
   adding .hgignore
   adding a
@@ -89,7 +89,7 @@ 
 
 auto EOL on CRLF file
 
-  $ $PYTHON -c 'file("a", "wb").write("a\r\nbbb\r\ncc\r\n\r\nd\r\ne")'
+  $ $PYTHON -c 'open("a", "wb").write(b"a\r\nbbb\r\ncc\r\n\r\nd\r\ne")'
   $ hg commit -m 'switch EOLs in a'
   $ hg --traceback --config patch.eol='auto' import eol.diff
   applying eol.diff
@@ -105,11 +105,11 @@ 
 
 auto EOL on new file or source without any EOL
 
-  $ $PYTHON -c 'file("noeol", "wb").write("noeol")'
+  $ $PYTHON -c 'open("noeol", "wb").write(b"noeol")'
   $ hg add noeol
   $ hg commit -m 'add noeol'
-  $ $PYTHON -c 'file("noeol", "wb").write("noeol\r\nnoeol\n")'
-  $ $PYTHON -c 'file("neweol", "wb").write("neweol\nneweol\r\n")'
+  $ $PYTHON -c 'open("noeol", "wb").write(b"noeol\r\nnoeol\n")'
+  $ $PYTHON -c 'open("neweol", "wb").write(b"neweol\nneweol\r\n")'
   $ hg add neweol
   $ hg diff --git > noeol.diff
   $ hg revert --no-backup noeol neweol
@@ -127,10 +127,10 @@ 
 
 Test --eol and binary patches
 
-  $ $PYTHON -c 'file("b", "wb").write("a\x00\nb\r\nd")'
+  $ $PYTHON -c 'open("b", "wb").write(b"a\x00\nb\r\nd")'
   $ hg ci -Am addb
   adding b
-  $ $PYTHON -c 'file("b", "wb").write("a\x00\nc\r\nd")'
+  $ $PYTHON -c 'open("b", "wb").write(b"a\x00\nc\r\nd")'
   $ hg diff --git > bin.diff
   $ hg revert --no-backup b