~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/fixture.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:
5
5
 
6
6
__metaclass__ = type
7
7
__all__ = [
 
8
    'CaptureOops',
8
9
    'PGBouncerFixture',
9
10
    'Urllib2Fixture',
10
11
    'ZopeAdapterFixture',
29
30
    uninstall_opener,
30
31
    )
31
32
from zope.component import (
 
33
    adapter,
32
34
    getGlobalSiteManager,
33
35
    provideHandler,
34
36
    )
41
43
    )
42
44
 
43
45
from canonical.config import config
 
46
from canonical.launchpad.webapp.errorlog import ErrorReportEvent
44
47
 
45
48
 
46
49
class PGBouncerFixture(pgbouncer.fixture.PGBouncerFixture):
200
203
        self.addCleanup(remove_wsgi_intercept, 'launchpad.dev', 80)
201
204
        install_opener()
202
205
        self.addCleanup(uninstall_opener)
 
206
 
 
207
 
 
208
class CaptureOops(Fixture):
 
209
    """Capture OOPSes notified via zope event notification.
 
210
 
 
211
    :ivar oopses: A list of the oops objects raised while the fixture is
 
212
        setup.
 
213
    """
 
214
    
 
215
    def setUp(self):
 
216
        super(CaptureOops, self).setUp()
 
217
        self.oopses = []
 
218
        self.useFixture(ZopeEventHandlerFixture(self._recordOops))
 
219
 
 
220
    @adapter(ErrorReportEvent)
 
221
    def _recordOops(self, event):
 
222
        self.oopses.append(event.object)
 
223