Patchwork py3: fix fix doctests to be bytes-safe

login
register
mail settings
Submitter Yuya Nishihara
Date March 31, 2018, 1:48 a.m.
Message ID <40be6a8728a046b3673a.1522460905@mimosa>
Download mbox | patch
Permalink /patch/30035/
State Accepted
Headers show

Comments

Yuya Nishihara - March 31, 2018, 1:48 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522459698 -32400
#      Sat Mar 31 10:28:18 2018 +0900
# Node ID 40be6a8728a046b3673a517af2a3e15574457728
# Parent  2a2ce93e12f4a70fa4aa2efae74658e43cc0e989
py3: fix fix doctests to be bytes-safe
Pulkit Goyal - March 31, 2018, 8:05 a.m.
On Sat, Mar 31, 2018 at 7:18 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1522459698 -32400
> #      Sat Mar 31 10:28:18 2018 +0900
> # Node ID 40be6a8728a046b3673a517af2a3e15574457728
> # Parent  2a2ce93e12f4a70fa4aa2efae74658e43cc0e989
> py3: fix fix doctests to be bytes-safe

Queued this. Many thanks!

Patch

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -303,33 +303,34 @@  def difflineranges(content1, content2):
     present in content1. Relies on mdiff's idea of where the line endings are in
     the string.
 
-    >>> lines = lambda s: '\\n'.join([c for c in s])
+    >>> from mercurial import pycompat
+    >>> lines = lambda s: b'\\n'.join([c for c in pycompat.iterbytestr(s)])
     >>> difflineranges2 = lambda a, b: difflineranges(lines(a), lines(b))
-    >>> difflineranges2('', '')
-    []
-    >>> difflineranges2('a', '')
+    >>> difflineranges2(b'', b'')
     []
-    >>> difflineranges2('', 'A')
-    [(1, 1)]
-    >>> difflineranges2('a', 'a')
+    >>> difflineranges2(b'a', b'')
     []
-    >>> difflineranges2('a', 'A')
+    >>> difflineranges2(b'', b'A')
     [(1, 1)]
-    >>> difflineranges2('ab', '')
+    >>> difflineranges2(b'a', b'a')
     []
-    >>> difflineranges2('', 'AB')
+    >>> difflineranges2(b'a', b'A')
+    [(1, 1)]
+    >>> difflineranges2(b'ab', b'')
+    []
+    >>> difflineranges2(b'', b'AB')
     [(1, 2)]
-    >>> difflineranges2('abc', 'ac')
+    >>> difflineranges2(b'abc', b'ac')
     []
-    >>> difflineranges2('ab', 'aCb')
+    >>> difflineranges2(b'ab', b'aCb')
     [(2, 2)]
-    >>> difflineranges2('abc', 'aBc')
+    >>> difflineranges2(b'abc', b'aBc')
     [(2, 2)]
-    >>> difflineranges2('ab', 'AB')
+    >>> difflineranges2(b'ab', b'AB')
     [(1, 2)]
-    >>> difflineranges2('abcde', 'aBcDe')
+    >>> difflineranges2(b'abcde', b'aBcDe')
     [(2, 2), (4, 4)]
-    >>> difflineranges2('abcde', 'aBCDe')
+    >>> difflineranges2(b'abcde', b'aBCDe')
     [(2, 4)]
     """
     ranges = []