File: test_splash_screen_log_handler.py

package info (click to toggle)
python-pyface 6.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,756 kB
  • sloc: python: 39,728; makefile: 79
file content (37 lines) | stat: -rw-r--r-- 942 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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'...')