py3: replace file() with open() in test-eol.t
authorPulkit Goyal <7895pulkit@gmail.com>
Sun, 11 Feb 2018 17:14:00 +0530
changeset 36030 b85b0bbed6de
parent 36029 d83fc41dabf3
child 36031 acda1977210c
py3: replace file() with open() in test-eol.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/D2129
tests/test-eol.t
--- a/tests/test-eol.t	Sun Feb 11 17:13:11 2018 +0530
+++ b/tests/test-eol.t	Sun Feb 11 17:14:00 2018 +0530
@@ -17,12 +17,12 @@
   >     msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
   > except ImportError:
   >     pass
-  > (old, new) = sys.argv[1] == 'LF' and ('\n', '\r\n') or ('\r\n', '\n')
+  > (old, new) = sys.argv[1] == 'LF' and (b'\n', b'\r\n') or (b'\r\n', b'\n')
   > print("%% switching encoding from %r to %r" % (old, new))
   > for path in sys.argv[2:]:
-  >     data = file(path, 'rb').read()
+  >     data = open(path, 'rb').read()
   >     data = data.replace(old, new)
-  >     file(path, 'wb').write(data)
+  >     open(path, 'wb').write(data)
   > EOF
 
   $ seteol () {