Commit 63dcee8d authored by Dieter Maurer's avatar Dieter Maurer Committed by GitHub

Merge pull request #360 from zopefoundation/blob_tests

make blob test `commit_from_wrong_partition` more robust
parents 1226c9d3 69d3828c
......@@ -49,7 +49,9 @@ logging:
>>> import logging, sys
>>> old_log_level = logging.getLogger().getEffectiveLevel()
>>> old_log_disabled = logging.getLogger().disabled
>>> logging.getLogger().setLevel(logging.DEBUG)
>>> logging.getLogger().disabled = False
>>> handler = logging.StreamHandler(sys.stdout)
>>> logging.getLogger().addHandler(handler)
......@@ -144,6 +146,7 @@ starting point, or just pick up where another iterator left off:
>>> it.close()
>>> logging.getLogger().setLevel(old_log_level)
>>> logging.getLogger().disabled = old_log_disabled
>>> logging.getLogger().removeHandler(handler)
......
......@@ -176,6 +176,8 @@ Make sure we can restore:
>>> logger = logging.getLogger('ZODB.FileStorage')
>>> logger.setLevel(logging.DEBUG)
>>> logger.addHandler(handler)
>>> log_disabled = logger.disabled
>>> logger.disabled = False
>>> index, pos, tid = fs._restore_index()
>>> index.items() == fs._index.items()
True
......@@ -186,6 +188,7 @@ cleanup
>>> fs.close()
>>> logger.setLevel(logging.NOTSET)
>>> logger.removeHandler(handler)
>>> logger.disabled = log_disabled
>>> sys.setrecursionlimit(old_limit)
"""
......
......@@ -83,6 +83,7 @@ class Handler(logging.Handler):
def setLoggerLevel(self, level=1):
self.level = level
self.oldlevels = {}
self.olddisabled = {}
def emit(self, record):
self.records.append(record)
......@@ -94,13 +95,16 @@ class Handler(logging.Handler):
for name in self.names:
logger = logging.getLogger(name)
self.oldlevels[name] = logger.level
self.olddisabled[name] = logger.disabled
logger.setLevel(self.level)
logger.disabled = False
logger.addHandler(self)
def uninstall(self):
for name in self.names:
logger = logging.getLogger(name)
logger.setLevel(self.oldlevels[name])
logger.disabled = self.olddisabled[name]
logger.removeHandler(self)
def __str__(self):
......
......@@ -379,6 +379,7 @@ def commit_from_wrong_partition():
>>> logger.propagate = False
>>> logger.setLevel(logging.DEBUG)
>>> logger.addHandler(handler)
>>> logger.disabled = False
>>> blob_storage = create_storage() # noqa: F821 undefined name
>>> database = DB(blob_storage)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment