Patchwork [6,of,6,py3] py3: convert system strings to bytes in doctest of formatter.py

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 17, 2017, 4:19 a.m.
Message ID <bb791130d27bbb7f0fa2.1505621945@mimosa>
Download mbox | patch
Permalink /patch/23982/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 17, 2017, 4:19 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1505619593 -32400
#      Sun Sep 17 12:39:53 2017 +0900
# Node ID bb791130d27bbb7f0fa2acbd39feec268997d362
# Parent  98d8cb8a7e43cb9500eef73ae3ff75308950f778
py3: convert system strings to bytes in doctest of formatter.py
Augie Fackler - Sept. 18, 2017, 4:07 p.m.
On Sun, Sep 17, 2017 at 01:19:05PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1505619593 -32400
> #      Sun Sep 17 12:39:53 2017 +0900
> # Node ID bb791130d27bbb7f0fa2acbd39feec268997d362
> # Parent  98d8cb8a7e43cb9500eef73ae3ff75308950f778
> py3: convert system strings to bytes in doctest of formatter.py

queued, thanks

Patch

diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -48,7 +48,8 @@  Doctest helper:
 ...     ui.verbose = verbose
 ...     ui.pushbuffer()
 ...     try:
-...         return fn(ui, ui.formatter(fn.__name__, opts))
+...         return fn(ui, ui.formatter(pycompat.sysbytes(fn.__name__),
+...                   pycompat.byteskwargs(opts)))
 ...     finally:
 ...         print(pycompat.sysstr(ui.popbuffer()), end='')
 
diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -51,7 +51,7 @@  testmod('mercurial.context')
 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
 testmod('mercurial.dispatch')
 testmod('mercurial.encoding')
-testmod('mercurial.formatter', py3=False)  # py3: write bytes to stdout
+testmod('mercurial.formatter')
 testmod('mercurial.hg')
 testmod('mercurial.hgweb.hgwebdir_mod', py3=False)  # py3: repr(bytes) ?
 testmod('mercurial.match')