Skip to content

Commit 411b4ac

Browse files
committed
Accommodate literal quote rendering in Pygments 2.21.0
Adjusted the test suite to accommodate for a change in Pygments 2.21.0 where the HtmlFormatter now renders " and ' characters literally rather than as HTML entities, which caused failures in tests that assert against the rendered output of html_error_template(). Fixes: sqlalchemy#440 Change-Id: I55e32d35bbcbe229b230e45831ee93beaca56cfa
1 parent eb5bdbf commit 411b4ac

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

‎doc/build/unreleased/440.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. change::
2+
:tags: bug, tests
3+
:tickets: 440
4+
5+
Adjusted the test suite to accommodate for a change in Pygments 2.21.0
6+
where the ``HtmlFormatter`` now renders ``"`` and ``'`` characters
7+
literally rather than as HTML entities, which caused failures in tests
8+
that assert against the rendered output of
9+
:func:`.html_error_template`.

‎test/test_exceptions.py‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,12 @@ def test_py_utf8_html_error_template(self):
154154
except:
155155
html_error = exceptions.html_error_template().render()
156156
assert "RuntimeError: test" in html_error.decode("utf-8")
157-
assert "foo = "日本"" in html_error.decode(
158-
"utf-8"
159-
) or "foo = "日本"" in html_error.decode("utf-8")
157+
assert (
158+
"foo = "日本"" in html_error.decode("utf-8")
159+
or "foo = "日本"" in html_error.decode("utf-8")
160+
# pygments 2.21.0 renders " and ' literally
161+
or 'foo = "日本"' in html_error.decode("utf-8")
162+
)
160163

161164
def test_py_unicode_error_html_error_template(self):
162165
try:
@@ -222,9 +225,12 @@ def test_utf8_format_exceptions_pygments(self):
222225
"foo.html", """# -*- coding: utf-8 -*-\n${'привет' + foobar}"""
223226
)
224227

225-
assert "&#39;привет&#39;</span>" in l.get_template(
226-
"foo.html"
227-
).render().decode("utf-8")
228+
rendered = l.get_template("foo.html").render().decode("utf-8")
229+
assert (
230+
"&#39;привет&#39;</span>" in rendered
231+
# pygments 2.21.0 renders " and ' literally
232+
or "'привет'</span>" in rendered
233+
)
228234

229235
@requires_no_pygments_exceptions
230236
def test_utf8_format_exceptions_no_pygments(self):
@@ -272,6 +278,8 @@ def test_custom_tback(self):
272278
assert (
273279
"".join(reversed(");touq&rab;touq&(oof")) in html_error
274280
or "".join(reversed(");43#&rab;43#&(oof")) in html_error
281+
# pygments 2.21.0 renders " and ' literally
282+
or "".join(reversed(')"rab"(oof')) in html_error
275283
)
276284

277285
def test_tback_no_trace_from_py_file(self):

0 commit comments

Comments
 (0)