summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2017-02-22 06:36:27 +0000
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2017-02-22 06:36:27 +0000
commit81b5f280b8cd66ecd1a02ac44d48b548d0d809c3 (patch)
tree021ee9eea257bf677b3e4d60d83da2b69942bad8 /tests
parent3acbe1076d0725349ffc7218e33d5b31152896ad (diff)
downloadlogutils-81b5f280b8cd66ecd1a02ac44d48b548d0d809c3.tar.gz
Updated ColorizingStreamHandler and test.
Thanks to Sam Bull for the patch.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_colorize.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_colorize.py b/tests/test_colorize.py
index 022b631..b4f9fa6 100644
--- a/tests/test_colorize.py
+++ b/tests/test_colorize.py
@@ -3,8 +3,8 @@
#
import logging
import logutils.colorize
-import os
import sys
+import tempfile
import unittest
if sys.version_info[0] < 3:
@@ -22,3 +22,18 @@ class ColorizeTest(unittest.TestCase):
logger.warning(u('Some unicode string with some \u015b\u0107\u017a\xf3\u0142 chars'))
finally:
logger.removeHandler(handler)
+
+ def test_colorize_to_file_with_unicode(self):
+ if sys.version_info >= (3, 0):
+ raise unittest.SkipTest('tests 2.x specific issue')
+ logger = logging.getLogger()
+ with tempfile.TemporaryFile() as logfile_handle:
+ handler = logutils.colorize.ColorizingStreamHandler(logfile_handle)
+ logger.addHandler(handler)
+ try:
+ logger.warning(u('Some unicode string'))
+ logfile_handle.seek(0)
+ self.assertTrue('Some unicode string' in logfile_handle.read())
+ finally:
+ logger.removeHandler(handler)
+ handler.close()