D3477: tests: port test-minirst.py to Python 3

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Tue May 8 04:27:26 UTC 2018


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  There are a few failures here, mostly around formatting lists. I'll
  fix that in a subsequent change.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3477

AFFECTED FILES
  tests/test-minirst.py

CHANGE DETAILS

diff --git a/tests/test-minirst.py b/tests/test-minirst.py
--- a/tests/test-minirst.py
+++ b/tests/test-minirst.py
@@ -7,28 +7,28 @@
 )
 
 def debugformat(text, form, **kwargs):
-    if form == 'html':
+    if form == b'html':
         print("html format:")
         out = minirst.format(text, style=form, **kwargs)
     else:
         print("%d column format:" % form)
         out = minirst.format(text, width=form, **kwargs)
 
     print("-" * 70)
     if type(out) == tuple:
-        print(out[0][:-1])
+        print(out[0][:-1].decode('utf8'))
         print("-" * 70)
-        print(stringutil.pprint(out[1], bprefix=False))
+        print(stringutil.pprint(out[1], bprefix=False).decode('utf8'))
     else:
-        print(out[:-1])
+        print(out[:-1].decode('utf8'))
     print("-" * 70)
     print()
 
 def debugformats(title, text, **kwargs):
     print("== %s ==" % title)
     debugformat(text, 60, **kwargs)
     debugformat(text, 30, **kwargs)
-    debugformat(text, 'html', **kwargs)
+    debugformat(text, b'html', **kwargs)
 
 paragraphs = b"""
 This is some text in the first paragraph.
@@ -39,7 +39,7 @@
  \n  \n   \nThe third and final paragraph.
 """
 
-debugformats(b'paragraphs', paragraphs)
+debugformats('paragraphs', paragraphs)
 
 definitions = b"""
 A Term
@@ -54,7 +54,7 @@
     Definition.
 """
 
-debugformats(b'definitions', definitions)
+debugformats('definitions', definitions)
 
 literals = br"""
 The fully minimized form is the most
@@ -78,7 +78,7 @@
       with '::' disappears in the final output.
 """
 
-debugformats(b'literals', literals)
+debugformats('literals', literals)
 
 lists = b"""
 - This is the first list item.
@@ -129,7 +129,7 @@
 * This is the third bullet
 """
 
-debugformats(b'lists', lists)
+debugformats('lists', lists)
 
 options = b"""
 There is support for simple option lists,
@@ -155,7 +155,7 @@
 --foo bar baz
 """
 
-debugformats(b'options', options)
+debugformats('options', options)
 
 fields = b"""
 :a: First item.
@@ -168,7 +168,7 @@
 :much too large: This key is big enough to get its own line.
 """
 
-debugformats(b'fields', fields)
+debugformats('fields', fields)
 
 containers = b"""
 Normal output.
@@ -186,14 +186,14 @@
       Debug output.
 """
 
-debugformats(b'containers (normal)', containers)
-debugformats(b'containers (verbose)', containers, keep=['verbose'])
-debugformats(b'containers (debug)', containers, keep=['debug'])
-debugformats(b'containers (verbose debug)', containers,
-            keep=['verbose', 'debug'])
+debugformats('containers (normal)', containers)
+debugformats('containers (verbose)', containers, keep=[b'verbose'])
+debugformats('containers (debug)', containers, keep=[b'debug'])
+debugformats('containers (verbose debug)', containers,
+            keep=[b'verbose', b'debug'])
 
 roles = b"""Please see :hg:`add`."""
-debugformats(b'roles', roles)
+debugformats('roles', roles)
 
 
 sections = b"""
@@ -209,7 +209,7 @@
 Markup: ``foo`` and :hg:`help`
 ------------------------------
 """
-debugformats(b'sections', sections)
+debugformats('sections', sections)
 
 
 admonitions = b"""
@@ -227,7 +227,7 @@
    This is danger
 """
 
-debugformats(b'admonitions', admonitions)
+debugformats('admonitions', admonitions)
 
 comments = b"""
 Some text.
@@ -243,7 +243,7 @@
 Empty comment above
 """
 
-debugformats(b'comments', comments)
+debugformats('comments', comments)
 
 
 data = [[b'a', b'b', b'c'],
@@ -253,16 +253,16 @@
 rst = minirst.maketable(data, 2, True)
 table = b''.join(rst)
 
-print(table)
+print(table.decode('utf8'))
 
-debugformats(b'table', table)
+debugformats('table', table)
 
 data = [[b's', b'long', b'line\ngoes on here'],
         [b'', b'xy', b'tried to fix here\n        by indenting']]
 
 rst = minirst.maketable(data, 1, False)
 table = b''.join(rst)
 
-print(table)
+print(table.decode('utf8'))
 
-debugformats(b'table+nl', table)
+debugformats('table+nl', table)



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list