From 1699701fd132c19974be66c5664a88a90a32a3d2 Mon Sep 17 00:00:00 2001 From: gbrandl Date: Thu, 25 Jan 2007 20:00:35 +0100 Subject: [svn] - add missing example files - add "outencoding" option to formatters - improve cmdline error reporting --- tests/test_basic_api.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tests/test_basic_api.py') diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py index a8b4ea96..592cfb25 100644 --- a/tests/test_basic_api.py +++ b/tests/test_basic_api.py @@ -12,7 +12,7 @@ import StringIO import random from pygments import lexers, formatters, format -from pygments.token import _TokenType +from pygments.token import _TokenType, Text from pygments.lexer import RegexLexer test_content = [chr(i) for i in xrange(33, 128)] * 5 @@ -89,6 +89,26 @@ class FormattersTest(unittest.TestCase): inst.get_style_defs() inst.format(ts, out) + def test_encodings(self): + from pygments.formatters import HtmlFormatter + + # unicode output + fmt = HtmlFormatter() + tokens = [(Text, u"ä")] + out = format(tokens, fmt) + self.assert_(type(out) is unicode) + self.assert_(u"ä" in out) + + # encoding option + fmt = HtmlFormatter(encoding="latin1") + tokens = [(Text, u"ä")] + self.assert_(u"ä".encode("latin1") in format(tokens, fmt)) + + # encoding and outencoding option + fmt = HtmlFormatter(encoding="latin1", outencoding="utf8") + tokens = [(Text, u"ä")] + self.assert_(u"ä".encode("utf8") in format(tokens, fmt)) + def test_styles(self): from pygments.formatters import HtmlFormatter fmt = HtmlFormatter(style="pastie") -- cgit v1.2.1