~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/__init__.py

  • Committer: Robert Collins
  • Date: 2011-10-17 07:58:30 UTC
  • mto: This revision was merged to the branch mainline in revision 14213.
  • Revision ID: robertc@robertcollins.net-20111017075830-ltysmkm13s5y3tqg
Give CaptureOops a better home and a focused test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
    'api_url',
15
15
    'BrowserTestCase',
16
16
    'build_yui_unittest_suite',
17
 
    'CaptureOops',
18
17
    'celebrity_logged_in',
19
18
    'ExpectedException',
20
19
    'extract_lp_cache',
98
97
from testtools.matchers import MatchesRegex
99
98
from testtools.testcase import ExpectedException as TTExpectedException
100
99
import transaction
101
 
from zope.component import (
102
 
    adapter,
103
 
    getUtility,
104
 
    )
 
100
from zope.component import getUtility
105
101
import zope.event
106
102
from zope.interface.verify import verifyClass
107
103
from zope.security.proxy import (
121
117
    start_sql_logging,
122
118
    stop_sql_logging,
123
119
    )
124
 
from canonical.launchpad.webapp.errorlog import ErrorReportEvent
125
120
from canonical.launchpad.webapp.interaction import ANONYMOUS
126
121
from canonical.launchpad.webapp.servers import (
127
122
    LaunchpadTestRequest,
165
160
    launchpadlib_for,
166
161
    oauth_access_token_for,
167
162
    )
168
 
from lp.testing.fixture import ZopeEventHandlerFixture
 
163
from lp.testing.fixture import CaptureOops
169
164
from lp.testing.karma import KarmaRecorder
170
165
 
171
166
# The following names have been imported for the purpose of being
1328
1323
            result.write(next_char)
1329
1324
        now = time.time()
1330
1325
    return result.getvalue()
1331
 
 
1332
 
 
1333
 
class CaptureOops(fixtures.Fixture):
1334
 
    """Capture OOPSes notified via zope event notification.
1335
 
 
1336
 
    :ivar oopses: A list of the oops objects raised while the fixture is
1337
 
        setup.
1338
 
    """
1339
 
    
1340
 
    def setUp(self):
1341
 
        super(CaptureOops, self).setUp()
1342
 
        self.oopses = []
1343
 
        self.useFixture(ZopeEventHandlerFixture(self._recordOops))
1344
 
 
1345
 
    @adapter(ErrorReportEvent)
1346
 
    def _recordOops(self, event):
1347
 
        self.oopses.append(event.object)
1348