Patchwork [2,of,6] py3: byte-stringify test-config.t and test-config-env.py

login
register
mail settings
Submitter Yuya Nishihara
Date March 4, 2018, 9:41 p.m.
Message ID <794b80520f0f47171ccb.1520199697@mimosa>
Download mbox | patch
Permalink /patch/29003/
State Accepted
Headers show

Comments

Yuya Nishihara - March 4, 2018, 9:41 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1520195186 18000
#      Sun Mar 04 15:26:26 2018 -0500
# Node ID 794b80520f0f47171ccb1e2db142e9bff1351cde
# Parent  f7cd53c5127f248f5d075ad28b6be82558b7c35d
py3: byte-stringify test-config.t and test-config-env.py

Patch

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -47,6 +47,8 @@  test-commit-amend.t
 test-commit-unresolved.t
 test-commit.t
 test-completion.t
+test-config-env.py
+test-config.t
 test-conflict.t
 test-confused-revert.t
 test-contrib-check-code.t
diff --git a/tests/test-config-env.py b/tests/test-config-env.py
--- a/tests/test-config-env.py
+++ b/tests/test-config-env.py
@@ -11,24 +11,24 @@  from mercurial import (
     util,
 )
 
-testtmp = encoding.environ['TESTTMP']
+testtmp = encoding.environ[b'TESTTMP']
 
 # prepare hgrc files
 def join(name):
     return os.path.join(testtmp, name)
 
-with open(join('sysrc'), 'w') as f:
-    f.write('[ui]\neditor=e0\n[pager]\npager=p0\n')
+with open(join(b'sysrc'), 'wb') as f:
+    f.write(b'[ui]\neditor=e0\n[pager]\npager=p0\n')
 
-with open(join('userrc'), 'w') as f:
-    f.write('[ui]\neditor=e1')
+with open(join(b'userrc'), 'wb') as f:
+    f.write(b'[ui]\neditor=e1')
 
 # replace rcpath functions so they point to the files above
 def systemrcpath():
-    return [join('sysrc')]
+    return [join(b'sysrc')]
 
 def userrcpath():
-    return [join('userrc')]
+    return [join(b'userrc')]
 
 rcutil.systemrcpath = systemrcpath
 rcutil.userrcpath = userrcpath
@@ -41,9 +41,10 @@  def printconfigs(env):
     ui = uimod.ui.load()
     for section, name, value in ui.walkconfig():
         source = ui.configsource(section, name)
-        print('%s.%s=%s # %s' % (section, name, value, util.pconvert(source)))
-    print('')
+        util.stdout.write(b'%s.%s=%s # %s\n'
+                          % (section, name, value, util.pconvert(source)))
+    util.stdout.write(b'\n')
 
 # environment variable overrides
 printconfigs({})
-printconfigs({'EDITOR': 'e2', 'PAGER': 'p2'})
+printconfigs({b'EDITOR': b'e2', b'PAGER': b'p2'})
diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -88,7 +88,7 @@  Test empty config source:
 
   $ cat <<EOF > emptysource.py
   > def reposetup(ui, repo):
-  >     ui.setconfig('empty', 'source', 'value')
+  >     ui.setconfig(b'empty', b'source', b'value')
   > EOF
   $ cp .hg/hgrc .hg/hgrc.orig
   $ cat <<EOF >> .hg/hgrc