Skip to content

Commit

Permalink
Merge pull request #31 from enthought/fix-unicode-splash-screen-handler
Browse files Browse the repository at this point in the history
Fix SplashScreenLogHandler with unicode messages
  • Loading branch information
Jonathan March authored and Jonathan March committed Apr 6, 2012
2 parents 3816c8f + 8034a3a commit b04b859
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyface/splash_screen_log_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, splash_screen):
def emit(self, record):
""" Emits the log record. """

self._splash_screen.text = str(record.getMessage()) + '...'
self._splash_screen.text = unicode(record.getMessage()) + u'...'

return

Expand Down
Empty file added pyface/tests/__init__.py
Empty file.
36 changes: 36 additions & 0 deletions pyface/tests/test_splash_screen_log_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from __future__ import absolute_import

import unittest

from traits.api import Any, HasTraits, Unicode

from ..splash_screen_log_handler import SplashScreenLogHandler


class DummySplashScreen(HasTraits):
text = Unicode(u'original')

class DummyRecord(object):
def __init__(self, message):
self.message = message

def getMessage(self):
return self.message


class TestSplashScreenLogHandler(unittest.TestCase):
def setUp(self):
self.ss = DummySplashScreen()
self.sslh = SplashScreenLogHandler(self.ss)

def test_unicode_message(self):
self.assertEqual(self.ss.text, u'original')
message = u'G\u00f6khan'
self.sslh.emit(DummyRecord(message))
self.assertEqual(self.ss.text, message + u'...')

def test_ascii_message(self):
message = 'Goekhan'
self.sslh.emit(DummyRecord(message))
self.assertEqual(self.ss.text, message + u'...')

0 comments on commit b04b859

Please sign in to comment.