This commit is contained in:
Florian Bruhin 2014-08-05 23:23:15 +02:00
parent 60d4dafbbb
commit 7818366f0a
3 changed files with 9 additions and 9 deletions

View File

@ -24,7 +24,7 @@ Module attributes:
pyeval_output: The output of the last :pyeval command.
"""
import html
import html as pyhtml
from PyQt5.QtNetwork import QNetworkReply
@ -112,13 +112,13 @@ class QuteHandlers:
@classmethod
def pyeval(cls):
"""Handler for qute:pyeval. Return HTML content as bytes."""
text = html.escape(pyeval_output)
text = pyhtml.escape(pyeval_output)
return _get_html('pyeval', '<pre>{}</pre>'.format(text))
@classmethod
def version(cls):
"""Handler for qute:version. Return HTML content as bytes."""
text = html.escape(version.version())
text = pyhtml.escape(version.version())
html = '<h1>Version info</h1>'
html += '<p>{}</p>'.format(text.replace('\n', '<br/>'))
html += '<h1>Copyright info</h1>'
@ -132,7 +132,7 @@ class QuteHandlers:
if logutils.ram_handler is None:
text = "Log output was disabled."
else:
text = html.escape(logutils.ram_handler.dump_log())
text = pyhtml.escape(logutils.ram_handler.dump_log())
return _get_html('log', '<pre>{}</pre>'.format(text))
@classmethod

View File

@ -1139,12 +1139,12 @@ class FontTests(unittest.TestCase):
def test_transform(self):
"""Test transform."""
for string, desc in self.TESTS.items():
with self.subTest(val=val):
with self.subTest(string=string, desc=desc):
with self.subTest(t="t1"):
self.assertEqual(self.t.transform(string), string, string)
with self.subTest(t="t2"):
self.assertEqual(Font(self.t2.transform(string)),
Font.fromdesc(desc), string)
Font.fromdesc(desc), string)
def test_transform_empty(self):
"""Test transform with an empty value."""

View File

@ -22,7 +22,7 @@
import re
import os
import sys
import html
import html as pyhtml
import logging
from contextlib import contextmanager
from logging import getLogger
@ -383,7 +383,7 @@ class HTMLFormatter(logging.Formatter):
for field in ['msg', 'filename', 'funcName', 'levelname', 'module',
'name', 'pathname', 'processName', 'threadName']:
data = str(getattr(record, field))
setattr(record, field, html.escape(data))
setattr(record, field, pyhtml.escape(data))
message = super().format(record)
if not message.endswith(self._colordict['reset']):
message += self._colordict['reset']
@ -391,4 +391,4 @@ class HTMLFormatter(logging.Formatter):
def formatTime(self, record, datefmt=None):
out = super().formatTime(record, datefmt)
return html.escape(out)
return pyhtml.escape(out)