Patchwork [6,of,6] py3: avoid b'' output in test-hgweb-non-interactive.t

login
register
mail settings
Submitter Matt Harbison
Date Sept. 30, 2018, 5:46 a.m.
Message ID <ff3aa78f7d11f0652a94.1538286385@Envy>
Download mbox | patch
Permalink /patch/35215/
State Accepted
Headers show

Comments

Matt Harbison - Sept. 30, 2018, 5:46 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1538284546 14400
#      Sun Sep 30 01:15:46 2018 -0400
# Node ID ff3aa78f7d11f0652a949a8b4064fc70481bcf5b
# Parent  a690c4f6b7a38a09346dcf51691fd2ccddefaa12
py3: avoid b'' output in test-hgweb-non-interactive.t

I couldn't figure out how to get the list to print without b'' with
pycompat.write(), without converted each element to str.
Yuya Nishihara - Sept. 30, 2018, 12:09 p.m.
On Sun, 30 Sep 2018 01:46:25 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1538284546 14400
> #      Sun Sep 30 01:15:46 2018 -0400
> # Node ID ff3aa78f7d11f0652a949a8b4064fc70481bcf5b
> # Parent  a690c4f6b7a38a09346dcf51691fd2ccddefaa12
> py3: avoid b'' output in test-hgweb-non-interactive.t
> 
> I couldn't figure out how to get the list to print without b'' with
> pycompat.write(), without converted each element to str.

stringutil.pprint() can be used.

Patch

diff --git a/tests/test-hgweb-non-interactive.t b/tests/test-hgweb-non-interactive.t
--- a/tests/test-hgweb-non-interactive.t
+++ b/tests/test-hgweb-non-interactive.t
@@ -12,7 +12,9 @@  by the WSGI standard and strictly implem
   > import sys
   > from mercurial import (
   >     dispatch,
+  >     encoding,
   >     hg,
+  >     pycompat,
   >     ui as uimod,
   >     util,
   > )
@@ -68,13 +70,15 @@  by the WSGI standard and strictly implem
   > i = hgweb(b'.')
   > for c in i(env, startrsp):
   >     pass
-  > print('---- ERRORS')
-  > print(errors.getvalue())
+  > sys.stdout.flush()
+  > pycompat.stdout.write(b'---- ERRORS\n')
+  > pycompat.stdout.write(b'%s\n' % errors.getvalue())
   > print('---- OS.ENVIRON wsgi variables')
   > print(sorted([x for x in os.environ if x.startswith('wsgi')]))
   > print('---- request.ENVIRON wsgi variables')
   > with i._obtainrepo() as repo:
-  >     print(sorted([x for x in repo.ui.environ if x.startswith(b'wsgi')]))
+  >     print(sorted([encoding.strfromlocal(x) for x in repo.ui.environ
+  >                   if x.startswith(b'wsgi')]))
   > EOF
   $ "$PYTHON" request.py
   ---- STATUS