~certify-web-dev/twisted/certify-staging

« back to all changes in this revision

Viewing changes to twisted/test/test_log.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-01-02 19:38:17 UTC
  • mfrom: (2.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100102193817-jphp464ppwh7dulg
Tags: 9.0.0-1
* python-twisted: Depend on the python-twisted-* 9.0 packages.
* python-twisted: Depend on python-zope.interface only. Closes: #557781.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2001-2008 Twisted Matrix Laboratories.
 
1
# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
2
2
# See LICENSE for details.
3
3
 
4
4
"""
25
25
 
26
26
    def setUp(self):
27
27
        self.catcher = []
28
 
        observer = self.catcher.append
29
 
        log.addObserver(observer)
30
 
        self.addCleanup(log.removeObserver, observer)
 
28
        self.observer = self.catcher.append
 
29
        log.addObserver(self.observer)
 
30
        self.addCleanup(log.removeObserver, self.observer)
31
31
 
32
32
 
33
33
    def testObservation(self):
120
120
        L{twisted.python.log.showwarning} emits the warning as a message
121
121
        to the Twisted logging system.
122
122
        """
123
 
        log.showwarning(
 
123
        publisher = log.LogPublisher()
 
124
        publisher.addObserver(self.observer)
 
125
 
 
126
        publisher.showwarning(
124
127
            FakeWarning("unique warning message"), FakeWarning,
125
128
            "warning-filename.py", 27)
126
129
        event = self.catcher.pop()
133
136
        # Python 2.6 requires that any function used to override the
134
137
        # warnings.showwarning API accept a "line" parameter or a
135
138
        # deprecation warning is emitted.
136
 
        log.showwarning(
 
139
        publisher.showwarning(
137
140
            FakeWarning("unique warning message"), FakeWarning,
138
141
            "warning-filename.py", 27, line=object())
139
142
        event = self.catcher.pop()
251
254
    def testSingleUnicode(self):
252
255
        self.lp.msg(u"Hello, \N{VULGAR FRACTION ONE HALF} world.")
253
256
        self.assertEquals(len(self.out), 1)
254
 
        self.assertIn('with str error Traceback', self.out[0])
 
257
        self.assertIn('with str error', self.out[0])
255
258
        self.assertIn('UnicodeEncodeError', self.out[0])
256
259
 
257
260