changeset 38119:b95a6fb7ae66

py3: fix .write() calls in few tests This patch adds b'' prefixes to make sure we write bytes and add `and None` in the end to suppress the output by .write() calls. Differential Revision: https://phab.mercurial-scm.org/D3610
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 19 May 2018 18:52:56 +0530
parents e887381e2976
children 307b19c7c043
files tests/test-commit-interactive-curses.t tests/test-hardlinks.t tests/test-import-merge.t tests/test-revert-interactive.t
diffstat 4 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-commit-interactive-curses.t	Sat May 19 18:51:14 2018 +0530
+++ b/tests/test-commit-interactive-curses.t	Sat May 19 18:52:56 2018 +0530
@@ -68,7 +68,7 @@
 Committing only one file
 
   $ echo "a" >> a
-  >>> open('b', 'wb').write("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n")
+  >>> open('b', 'wb').write(b"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n") and None
   $ hg add b
   $ cat <<EOF >testModeCommands
   > TOGGLE
--- a/tests/test-hardlinks.t	Sat May 19 18:51:14 2018 +0530
+++ b/tests/test-hardlinks.t	Sat May 19 18:52:56 2018 +0530
@@ -122,7 +122,7 @@
   $ cd r3/d1
   >>> f = open('data1', 'wb')
   >>> for x in range(10000):
-  ...     f.write("%s\n" % str(x))
+  ...     f.write(b"%d\n" % x) and None
   >>> f.close()
   $ for j in 0 1 2 3 4 5 6 7 8 9; do
   >   cat data1 >> f2
--- a/tests/test-import-merge.t	Sat May 19 18:51:14 2018 +0530
+++ b/tests/test-import-merge.t	Sat May 19 18:52:56 2018 +0530
@@ -143,7 +143,7 @@
   $ hg export 2 | head -7 > ../a.patch
   $ hg export tip > out
   >>> apatch = open("../a.patch", "ab")
-  >>> apatch.write("".join(open("out").readlines()[7:]))
+  >>> apatch.write(b"".join(open("out", 'rb').readlines()[7:])) and None
 
   $ cd ..
   $ hg clone -qr0 repo3 repo3-clone
--- a/tests/test-revert-interactive.t	Sat May 19 18:51:14 2018 +0530
+++ b/tests/test-revert-interactive.t	Sat May 19 18:52:56 2018 +0530
@@ -22,16 +22,16 @@
   $ mkdir -p a/folder1 a/folder2
   $ cd a
   $ hg init
-  >>> open('f', 'wb').write("1\n2\n3\n4\n5\n")
+  >>> open('f', 'wb').write(b"1\n2\n3\n4\n5\n") and None
   $ hg add f ; hg commit -m "adding f"
   $ cat f > folder1/g ; hg add folder1/g ; hg commit -m "adding folder1/g"
   $ cat f > folder2/h ; hg add folder2/h ; hg commit -m "adding folder2/h"
   $ cat f > folder1/i ; hg add folder1/i ; hg commit -m "adding folder1/i"
-  >>> open('f', 'wb').write("a\n1\n2\n3\n4\n5\nb\n")
+  >>> open('f', 'wb').write(b"a\n1\n2\n3\n4\n5\nb\n") and None
   $ hg commit -m "modifying f"
-  >>> open('folder1/g', 'wb').write("c\n1\n2\n3\n4\n5\nd\n")
+  >>> open('folder1/g', 'wb').write(b"c\n1\n2\n3\n4\n5\nd\n") and None
   $ hg commit -m "modifying folder1/g"
-  >>> open('folder2/h', 'wb').write("e\n1\n2\n3\n4\n5\nf\n")
+  >>> open('folder2/h', 'wb').write(b"e\n1\n2\n3\n4\n5\nf\n") and None
   $ hg commit -m "modifying folder2/h"
   $ hg tip
   changeset:   6:59dd6e4ab63a
@@ -182,7 +182,7 @@
   
   $ ls folder1/
   g
-  >>> open('folder1/g', 'wb').write("1\n2\n3\n4\n5\nd\n")
+  >>> open('folder1/g', 'wb').write(b"1\n2\n3\n4\n5\nd\n") and None
 
 
   $ hg update -C 6