py3: suppress the output from .write() calls in few tests
authorPulkit Goyal <7895pulkit@gmail.com>
Sat, 19 May 2018 18:43:13 +0530
changeset 38113 0a10f142299d
parent 38112 ce307af030a2
child 38114 8fa2b5c85a46
py3: suppress the output from .write() calls in few tests Differential Revision: https://phab.mercurial-scm.org/D3604
tests/test-fileset.t
tests/test-import-git.t
tests/test-parse-date.t
tests/test-revlog.t
tests/test-symlink-placeholder.t
--- a/tests/test-fileset.t	Sat May 19 18:42:18 2018 +0530
+++ b/tests/test-fileset.t	Sat May 19 18:43:13 2018 +0530
@@ -180,7 +180,7 @@
 
 Test files properties
 
-  >>> open('bin', 'wb').write(b'\0a')
+  >>> open('bin', 'wb').write(b'\0a') and None
   $ fileset 'binary()'
   $ fileset 'binary() and unknown()'
   bin
@@ -219,8 +219,8 @@
   $ hg --config ui.portablefilenames=ignore add con.xml
 #endif
 
-  >>> open('1k', 'wb').write(b' '*1024)
-  >>> open('2k', 'wb').write(b' '*2048)
+  >>> open('1k', 'wb').write(b' '*1024) and None
+  >>> open('2k', 'wb').write(b' '*2048) and None
   $ hg add 1k 2k
   $ fileset 'size("bar")'
   hg: parse error: couldn't parse size: bar
@@ -391,9 +391,9 @@
   b2
   c1
 
-  >>> open('dos', 'wb').write("dos\r\n")
-  >>> open('mixed', 'wb').write("dos\r\nunix\n")
-  >>> open('mac', 'wb').write("mac\r")
+  >>> open('dos', 'wb').write(b"dos\r\n") and None
+  >>> open('mixed', 'wb').write(b"dos\r\nunix\n") and None
+  >>> open('mac', 'wb').write(b"mac\r") and None
   $ hg add dos mixed mac
 
 (remove a1, to examine safety of 'eol' on removed files)
--- a/tests/test-import-git.t	Sat May 19 18:42:18 2018 +0530
+++ b/tests/test-import-git.t	Sat May 19 18:43:13 2018 +0530
@@ -566,7 +566,7 @@
   >>> fp = open('binary.diff', 'rb')
   >>> data = fp.read()
   >>> fp.close()
-  >>> open('binary.diff', 'wb').write(data.replace(b'\n', b'\r\n'))
+  >>> open('binary.diff', 'wb').write(data.replace(b'\n', b'\r\n')) and None
   $ rm binary2
   $ hg import --no-commit binary.diff
   applying binary.diff
--- a/tests/test-parse-date.t	Sat May 19 18:42:18 2018 +0530
+++ b/tests/test-parse-date.t	Sat May 19 18:43:13 2018 +0530
@@ -243,8 +243,8 @@
   >>> today = datetime.date.today().strftime("%b %d")
   >>> yesterday = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%b %d")
   >>> dates = open('dates', 'w')
-  >>> dates.write(today + '\n')
-  >>> dates.write(yesterday + '\n')
+  >>> dates.write(today + '\n') and None
+  >>> dates.write(yesterday + '\n') and None
   >>> dates.close()
   $ hg ci -d "`sed -n '1p' dates`" -m "today is a good day to code"
   $ hg log -d today --template '{desc}\n'
--- a/tests/test-revlog.t	Sat May 19 18:42:18 2018 +0530
+++ b/tests/test-revlog.t	Sat May 19 18:43:13 2018 +0530
@@ -4,7 +4,7 @@
 Flags on revlog version 0 are rejected
 
   >>> with open('.hg/store/00changelog.i', 'wb') as fh:
-  ...     fh.write(b'\x00\x01\x00\x00')
+  ...     fh.write(b'\x00\x01\x00\x00') and None
 
   $ hg log
   abort: unknown flags (0x01) in version 0 revlog 00changelog.i!
@@ -13,7 +13,7 @@
 Unknown flags on revlog version 1 are rejected
 
   >>> with open('.hg/store/00changelog.i', 'wb') as fh:
-  ...     fh.write(b'\x00\x04\x00\x01')
+  ...     fh.write(b'\x00\x04\x00\x01') and None
 
   $ hg log
   abort: unknown flags (0x04) in version 1 revlog 00changelog.i!
@@ -22,7 +22,7 @@
 Unknown version is rejected
 
   >>> with open('.hg/store/00changelog.i', 'wb') as fh:
-  ...     fh.write(b'\x00\x00\x00\x02')
+  ...     fh.write(b'\x00\x00\x00\x02') and None
 
   $ hg log
   abort: unknown version (2) in revlog 00changelog.i!
--- a/tests/test-symlink-placeholder.t	Sat May 19 18:42:18 2018 +0530
+++ b/tests/test-symlink-placeholder.t	Sat May 19 18:43:13 2018 +0530
@@ -50,13 +50,13 @@
 
 Write binary data to the placeholder:
 
-  >>> open('b', 'w').write('this is a binary\0')
+  >>> open('b', 'w').write('this is a binary\0') and None
   $ hg --config extensions.n=$TESTTMP/nolink.py st --debug
   ignoring suspect symlink placeholder "b"
 
 Write a long string to the placeholder:
 
-  >>> open('b', 'w').write('this' * 1000)
+  >>> open('b', 'w').write('this' * 1000) and None
   $ hg --config extensions.n=$TESTTMP/nolink.py st --debug
   ignoring suspect symlink placeholder "b"
 
@@ -68,7 +68,7 @@
 
 Write a valid string to the placeholder:
 
-  >>> open('b', 'w').write('this')
+  >>> open('b', 'w').write('this') and None
   $ hg --config extensions.n=$TESTTMP/nolink.py st --debug
   M b
   $ hg --config extensions.n=$TESTTMP/nolink.py ci -m1