tests: port test-minirst.py to Python 3
authorAugie Fackler <augie@google.com>
Fri, 27 Apr 2018 00:46:05 -0400
changeset 37882 3d24f708f7b6
parent 37881 672f51ec0d47
child 37883 a61583cba509
tests: port test-minirst.py to Python 3 There are a few failures here, mostly around formatting lists. I'll fix that in a subsequent change. Differential Revision: https://phab.mercurial-scm.org/D3477
tests/test-minirst.py
--- a/tests/test-minirst.py	Fri Apr 27 00:31:57 2018 -0400
+++ b/tests/test-minirst.py	Fri Apr 27 00:46:05 2018 -0400
@@ -7,7 +7,7 @@
 )
 
 def debugformat(text, form, **kwargs):
-    if form == 'html':
+    if form == b'html':
         print("html format:")
         out = minirst.format(text, style=form, **kwargs)
     else:
@@ -16,11 +16,11 @@
 
     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()
 
@@ -28,7 +28,7 @@
     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,9 +253,9 @@
 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']]
@@ -263,6 +263,6 @@
 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)