1
# -*- test-case-name: "twisted.test.test_log" -*-
2
1
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3
2
# See LICENSE for details.
7
8
from twisted.trial import unittest
9
10
from twisted.python import log
73
74
self.assertEquals(len(L2), 3)
74
75
self.assertEquals(L1[2]['message'], ("Howdy, y'all.",))
75
76
self.assertEquals(L2[2]['message'], ("Howdy, y'all.",))
80
def write(self, bytes):
87
class LogPublisherTestCase(unittest.TestCase):
91
self._origEncoding = sys.getdefaultencoding()
92
sys.setdefaultencoding('ascii')
94
def tearDownClass(self):
95
sys.setdefaultencoding(self._origEncoding)
97
del sys.setdefaultencoding
100
self.out = FakeFile()
101
self.lp = log.LogPublisher()
102
self.flo = log.FileLogObserver(self.out)
103
self.lp.addObserver(self.flo.emit)
106
for chunk in self.out:
107
self.failUnless(isinstance(chunk, str), "%r was not a string" % (chunk,))
109
def testSingleString(self):
110
self.lp.msg("Hello, world.")
111
self.assertEquals(len(self.out), 1)
113
def testMultipleString(self):
114
# Test some stupid behavior that will be deprecated real soon.
115
# If you are reading this and trying to learn how the logging
116
# system works, *do not use this feature*.
117
self.lp.msg("Hello, ", "world.")
118
self.assertEquals(len(self.out), 1)
120
def testSingleUnicode(self):
123
self.lp.msg, u"Hello, \N{VULGAR FRACTION ONE HALF} world.")
124
self.assertEquals(len(self.out), 0)