Patchwork [2,of,3] py3: make test-template-engine.t bytes-safe

login
register
mail settings
Submitter Yuya Nishihara
Date March 16, 2018, 4:02 p.m.
Message ID <7977db549515436936f5.1521216172@mimosa>
Download mbox | patch
Permalink /patch/29565/
State Accepted
Headers show

Comments

Yuya Nishihara - March 16, 2018, 4:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521212353 -32400
#      Fri Mar 16 23:59:13 2018 +0900
# Node ID 7977db549515436936f56befb1b065d0b956996e
# Parent  a305e7f025b030a74ca178f722e7502d6c012d6a
py3: make test-template-engine.t bytes-safe

Patch

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -388,6 +388,7 @@  test-subrepo.t
 test-symlinks.t
 test-tag.t
 test-tags.t
+test-template-engine.t
 test-treemanifest.t
 test-unamend.t
 test-uncommit.t
diff --git a/tests/test-template-engine.t b/tests/test-template-engine.t
--- a/tests/test-template-engine.t
+++ b/tests/test-template-engine.t
@@ -2,6 +2,7 @@ 
   $ cat > engine.py << EOF
   > 
   > from mercurial import (
+  >     pycompat,
   >     templater,
   >     templateutil,
   > )
@@ -15,19 +16,20 @@ 
   >         props = self._defaults.copy()
   >         props.update(map)
   >         for k, v in props.items():
-  >             if k in ('templ', 'ctx', 'repo', 'revcache', 'cache', 'troubles'):
+  >             if k in (b'templ', b'ctx', b'repo', b'revcache', b'cache',
+  >                      b'troubles'):
   >                 continue
   >             if callable(v) and getattr(v, '_requires', None) is None:
   >                 props = self._resources.copy()
   >                 props.update(map)
-  >                 v = v(**props)
+  >                 v = v(**pycompat.strkwargs(props))
   >             elif callable(v):
   >                 v = v(self, props)
   >             v = templateutil.stringify(v)
-  >             tmpl = tmpl.replace('{{%s}}' % k, v)
+  >             tmpl = tmpl.replace(b'{{%s}}' % k, v)
   >         yield tmpl
   > 
-  > templater.engines['my'] = mytemplater
+  > templater.engines[b'my'] = mytemplater
   > EOF
   $ hg init test
   $ echo '[extensions]' > test/.hg/hgrc