177
177
from lp.testing.fixture import CaptureOops
178
178
from lp.testing.karma import KarmaRecorder
179
import lp_sitecustomize
180
181
# The following names have been imported for the purpose of being
181
182
# exported. They are referred to here to silence lint warnings.
197
198
with_person_logged_in
202
"""Reset the logging system back to defaults
204
Currently, defaults means 'the way the Z3 testrunner sets it up'
205
plus customizations made in lp_sitecustomize
207
# Remove all handlers from non-root loggers, and remove the loggers too.
208
loggerDict = logging.Logger.manager.loggerDict
209
for name, logger in list(loggerDict.items()):
210
if name == 'pagetests-access':
211
# Don't reset the hit logger used by the test infrastructure.
213
if not isinstance(logger, logging.PlaceHolder):
214
for handler in list(logger.handlers):
215
logger.removeHandler(handler)
218
# Remove all handlers from the root logger
219
root = logging.getLogger('')
220
for handler in root.handlers:
221
root.removeHandler(handler)
223
# Set the root logger's log level back to the default level: WARNING.
224
root.setLevel(logging.WARNING)
226
# Clean out the guts of the logging module. We don't want handlers that
227
# have already been closed hanging around for the atexit handler to barf
229
del logging._handlerList[:]
230
logging._handlers.clear()
233
from zope.testing.testrunner.runner import Runner
234
from zope.testing.testrunner.logsupport import Logging
235
Logging(Runner()).global_setup()
236
lp_sitecustomize.customize_logger()
201
240
"""Provides a controllable implementation of time.time().
594
633
super(TestCase, self).setUp()
595
634
# Circular imports.
596
635
from lp.testing.factory import ObjectFactory
597
from canonical.testing.layers import LibrarianLayer
636
from lp.testing.layers import LibrarianLayer
598
637
self.factory = ObjectFactory()
599
638
# Record the oopses generated during the test run.
600
639
# You can call self.oops_capture.sync() to collect oopses from
840
879
# XXX wgrant 2011-03-09 bug=505913:
841
880
# TestTwistedJobRunner.test_timeout fails if this is at the
842
881
# module level. There is probably some hidden circular import.
843
from canonical.testing.layers import AppServerLayer
882
from lp.testing.layers import AppServerLayer
844
883
return AppServerLayer