From: Alex Morega Date: Sat, 18 May 2013 11:22:30 +0000 (+0300) Subject: unit test for dumping as utf-8 to a file X-Git-Tag: 2.7~63^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9b4af6da6858fb94fc828d1fb3b092aad289575;p=thirdparty%2Fjinja.git unit test for dumping as utf-8 to a file --- diff --git a/jinja2/testsuite/api.py b/jinja2/testsuite/api.py index 53854372..4f6a1d0e 100644 --- a/jinja2/testsuite/api.py +++ b/jinja2/testsuite/api.py @@ -9,6 +9,9 @@ :license: BSD, see LICENSE for more details. """ import unittest +import os +import tempfile +import shutil from jinja2.testsuite import JinjaTestCase @@ -167,6 +170,17 @@ class StreamingTestCase(JinjaTestCase): stream.disable_buffering() assert not stream.buffered + def test_dump_stream(self): + tmp = tempfile.mkdtemp() + try: + tmpl = env.from_string(u"\u2713") + stream = tmpl.stream() + stream.dump(os.path.join(tmp, 'dump.txt'), 'utf-8') + with open(os.path.join(tmp, 'dump.txt'), 'rb') as f: + self.assertEqual(f.read(), b'\xe2\x9c\x93') + finally: + shutil.rmtree(tmp) + class UndefinedTestCase(JinjaTestCase):