##// END OF EJS Templates
tests: port test-minirst.py to Python 3...
Augie Fackler -
r37899:3d24f708 default
parent child Browse files
Show More
@@ -7,7 +7,7 b' from mercurial.utils import ('
7 )
7 )
8
8
9 def debugformat(text, form, **kwargs):
9 def debugformat(text, form, **kwargs):
10 if form == 'html':
10 if form == b'html':
11 print("html format:")
11 print("html format:")
12 out = minirst.format(text, style=form, **kwargs)
12 out = minirst.format(text, style=form, **kwargs)
13 else:
13 else:
@@ -16,11 +16,11 b' def debugformat(text, form, **kwargs):'
16
16
17 print("-" * 70)
17 print("-" * 70)
18 if type(out) == tuple:
18 if type(out) == tuple:
19 print(out[0][:-1])
19 print(out[0][:-1].decode('utf8'))
20 print("-" * 70)
20 print("-" * 70)
21 print(stringutil.pprint(out[1], bprefix=False))
21 print(stringutil.pprint(out[1], bprefix=False).decode('utf8'))
22 else:
22 else:
23 print(out[:-1])
23 print(out[:-1].decode('utf8'))
24 print("-" * 70)
24 print("-" * 70)
25 print()
25 print()
26
26
@@ -28,7 +28,7 b' def debugformats(title, text, **kwargs):'
28 print("== %s ==" % title)
28 print("== %s ==" % title)
29 debugformat(text, 60, **kwargs)
29 debugformat(text, 60, **kwargs)
30 debugformat(text, 30, **kwargs)
30 debugformat(text, 30, **kwargs)
31 debugformat(text, 'html', **kwargs)
31 debugformat(text, b'html', **kwargs)
32
32
33 paragraphs = b"""
33 paragraphs = b"""
34 This is some text in the first paragraph.
34 This is some text in the first paragraph.
@@ -39,7 +39,7 b' This is some text in the first paragraph'
39 \n \n \nThe third and final paragraph.
39 \n \n \nThe third and final paragraph.
40 """
40 """
41
41
42 debugformats(b'paragraphs', paragraphs)
42 debugformats('paragraphs', paragraphs)
43
43
44 definitions = b"""
44 definitions = b"""
45 A Term
45 A Term
@@ -54,7 +54,7 b' Another Term'
54 Definition.
54 Definition.
55 """
55 """
56
56
57 debugformats(b'definitions', definitions)
57 debugformats('definitions', definitions)
58
58
59 literals = br"""
59 literals = br"""
60 The fully minimized form is the most
60 The fully minimized form is the most
@@ -78,7 +78,7 b' simply ends with space-double-colon. ::'
78 with '::' disappears in the final output.
78 with '::' disappears in the final output.
79 """
79 """
80
80
81 debugformats(b'literals', literals)
81 debugformats('literals', literals)
82
82
83 lists = b"""
83 lists = b"""
84 - This is the first list item.
84 - This is the first list item.
@@ -129,7 +129,7 b' Bullet lists are also detected:'
129 * This is the third bullet
129 * This is the third bullet
130 """
130 """
131
131
132 debugformats(b'lists', lists)
132 debugformats('lists', lists)
133
133
134 options = b"""
134 options = b"""
135 There is support for simple option lists,
135 There is support for simple option lists,
@@ -155,7 +155,7 b' marker after the option. It is treated a'
155 --foo bar baz
155 --foo bar baz
156 """
156 """
157
157
158 debugformats(b'options', options)
158 debugformats('options', options)
159
159
160 fields = b"""
160 fields = b"""
161 :a: First item.
161 :a: First item.
@@ -168,7 +168,7 b' Next list:'
168 :much too large: This key is big enough to get its own line.
168 :much too large: This key is big enough to get its own line.
169 """
169 """
170
170
171 debugformats(b'fields', fields)
171 debugformats('fields', fields)
172
172
173 containers = b"""
173 containers = b"""
174 Normal output.
174 Normal output.
@@ -186,14 +186,14 b' Normal output.'
186 Debug output.
186 Debug output.
187 """
187 """
188
188
189 debugformats(b'containers (normal)', containers)
189 debugformats('containers (normal)', containers)
190 debugformats(b'containers (verbose)', containers, keep=['verbose'])
190 debugformats('containers (verbose)', containers, keep=[b'verbose'])
191 debugformats(b'containers (debug)', containers, keep=['debug'])
191 debugformats('containers (debug)', containers, keep=[b'debug'])
192 debugformats(b'containers (verbose debug)', containers,
192 debugformats('containers (verbose debug)', containers,
193 keep=['verbose', 'debug'])
193 keep=[b'verbose', b'debug'])
194
194
195 roles = b"""Please see :hg:`add`."""
195 roles = b"""Please see :hg:`add`."""
196 debugformats(b'roles', roles)
196 debugformats('roles', roles)
197
197
198
198
199 sections = b"""
199 sections = b"""
@@ -209,7 +209,7 b' Subsection'
209 Markup: ``foo`` and :hg:`help`
209 Markup: ``foo`` and :hg:`help`
210 ------------------------------
210 ------------------------------
211 """
211 """
212 debugformats(b'sections', sections)
212 debugformats('sections', sections)
213
213
214
214
215 admonitions = b"""
215 admonitions = b"""
@@ -227,7 +227,7 b' admonitions = b"""'
227 This is danger
227 This is danger
228 """
228 """
229
229
230 debugformats(b'admonitions', admonitions)
230 debugformats('admonitions', admonitions)
231
231
232 comments = b"""
232 comments = b"""
233 Some text.
233 Some text.
@@ -243,7 +243,7 b' Some text.'
243 Empty comment above
243 Empty comment above
244 """
244 """
245
245
246 debugformats(b'comments', comments)
246 debugformats('comments', comments)
247
247
248
248
249 data = [[b'a', b'b', b'c'],
249 data = [[b'a', b'b', b'c'],
@@ -253,9 +253,9 b" data = [[b'a', b'b', b'c'],"
253 rst = minirst.maketable(data, 2, True)
253 rst = minirst.maketable(data, 2, True)
254 table = b''.join(rst)
254 table = b''.join(rst)
255
255
256 print(table)
256 print(table.decode('utf8'))
257
257
258 debugformats(b'table', table)
258 debugformats('table', table)
259
259
260 data = [[b's', b'long', b'line\ngoes on here'],
260 data = [[b's', b'long', b'line\ngoes on here'],
261 [b'', b'xy', b'tried to fix here\n by indenting']]
261 [b'', b'xy', b'tried to fix here\n by indenting']]
@@ -263,6 +263,6 b" data = [[b's', b'long', b'line\\ngoes on "
263 rst = minirst.maketable(data, 1, False)
263 rst = minirst.maketable(data, 1, False)
264 table = b''.join(rst)
264 table = b''.join(rst)
265
265
266 print(table)
266 print(table.decode('utf8'))
267
267
268 debugformats(b'table+nl', table)
268 debugformats('table+nl', table)
General Comments 0
You need to be logged in to leave comments. Login now