From e9b4af6da6858fb94fc828d1fb3b092aad289575 Mon Sep 17 00:00:00 2001 From: Alex Morega Date: Sat, 18 May 2013 14:22:30 +0300 Subject: [PATCH] unit test for dumping as utf-8 to a file --- jinja2/testsuite/api.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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): -- 2.47.2