py3: replace file() with open() in test-import.t
authorPulkit Goyal <7895pulkit@gmail.com>
Sun, 11 Feb 2018 17:08:40 +0530
changeset 36024 2a81ed6c3bb9
parent 36023 adec6374a0b2
child 36025 32695e525586
py3: replace file() with open() in test-import.t file() is not present in Python 3. This patch also adds a b'' prefix to make sure we write bytes in Python 3. Differential Revision: https://phab.mercurial-scm.org/D2123
tests/test-import.t
--- a/tests/test-import.t	Sun Feb 11 17:07:09 2018 +0530
+++ b/tests/test-import.t	Sun Feb 11 17:08:40 2018 +0530
@@ -56,7 +56,7 @@
   $ cat > dummypatch.py <<EOF
   > from __future__ import print_function
   > print('patching file a')
-  > file('a', 'wb').write('line2\n')
+  > open('a', 'wb').write(b'line2\n')
   > EOF
   $ hg clone -r0 a b
   adding changesets
@@ -291,7 +291,7 @@
   > msg.set_payload('email commit message\n' + patch)
   > msg['Subject'] = 'email patch'
   > msg['From'] = 'email patcher'
-  > file(sys.argv[2], 'wb').write(msg.as_string())
+  > open(sys.argv[2], 'wb').write(msg.as_string())
   > EOF
 
 
@@ -389,7 +389,7 @@
   > msg.set_payload('email patch\n\nnext line\n---\n' + patch)
   > msg['Subject'] = '[PATCH] email patch'
   > msg['From'] = 'email patcher'
-  > file(sys.argv[2], 'wb').write(msg.as_string())
+  > open(sys.argv[2], 'wb').write(msg.as_string())
   > EOF
 
 
@@ -829,7 +829,7 @@
   $ hg init binaryremoval
   $ cd binaryremoval
   $ echo a > a
-  $ $PYTHON -c "file('b', 'wb').write('a\x00b')"
+  $ $PYTHON -c "open('b', 'wb').write(b'a\x00b')"
   $ hg ci -Am addall
   adding a
   adding b