Patchwork [3,of,6,py3] py3: fix doctests in patch.py to be compatible with Python 3

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

Comments

Yuya Nishihara - Sept. 17, 2017, 4:19 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1505618596 -32400
#      Sun Sep 17 12:23:16 2017 +0900
# Node ID 32d2d4b802c30774e37a7c76ff4157ff369910aa
# Parent  32586281847e0c04512b3ace89315b69f0ac5b80
py3: fix doctests in patch.py to be compatible with Python 3

We were lucky that parsepatch() could concatenate a character slice as if
it were a list of chunks.

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1490,7 +1490,7 @@  def reversehunks(hunks):
     ...  5
     ...  d
     ... +lastline"""
-    >>> hunks = parsepatch(rawpatch)
+    >>> hunks = parsepatch([rawpatch])
     >>> hunkscomingfromfilterpatch = []
     >>> for h in hunks:
     ...     hunkscomingfromfilterpatch.append(h)
@@ -1501,7 +1501,7 @@  def reversehunks(hunks):
     >>> fp = util.stringio()
     >>> for c in reversedhunks:
     ...      c.write(fp)
-    >>> fp.seek(0)
+    >>> fp.seek(0) or None
     >>> reversedpatch = fp.read()
     >>> print(pycompat.sysstr(reversedpatch))
     diff --git a/folder1/g b/folder1/g
diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -57,7 +57,7 @@  testmod('mercurial.hgweb.hgwebdir_mod', 
 testmod('mercurial.match')
 testmod('mercurial.mdiff')
 testmod('mercurial.minirst')
-testmod('mercurial.patch', py3=False)  # py3: bytes[n], etc. ?
+testmod('mercurial.patch')
 testmod('mercurial.pathutil', py3=False)  # py3: os.sep
 testmod('mercurial.parser')
 testmod('mercurial.pycompat')