py3: replace file() with open() in test-encoding.t
file() is not present in Python 3.
This also makes sure we write things in bytes mode in Python 3.
Differential Revision: https://phab.mercurial-scm.org/D2130
--- a/tests/test-encoding.t Sun Feb 11 16:17:17 2018 +0530
+++ b/tests/test-encoding.t Sun Feb 11 17:14:59 2018 +0530
@@ -15,9 +15,9 @@
$ hg co
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ $PYTHON << EOF
- > f = file('latin-1', 'w'); f.write("latin-1 e' encoded: \xe9"); f.close()
- > f = file('utf-8', 'w'); f.write("utf-8 e' encoded: \xc3\xa9"); f.close()
- > f = file('latin-1-tag', 'w'); f.write("\xe9"); f.close()
+ > f = open('latin-1', 'wb'); f.write(b"latin-1 e' encoded: \xe9"); f.close()
+ > f = open('utf-8', 'wb'); f.write(b"utf-8 e' encoded: \xc3\xa9"); f.close()
+ > f = open('latin-1-tag', 'wb'); f.write(b"\xe9"); f.close()
> EOF
should fail with encoding error