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: ...@@ -49,7 +49,9 @@ logging:
>>> import logging, sys >>> import logging, sys
>>> old_log_level = logging.getLogger().getEffectiveLevel() >>> old_log_level = logging.getLogger().getEffectiveLevel()
>>> old_log_disabled = logging.getLogger().disabled
>>> logging.getLogger().setLevel(logging.DEBUG) >>> logging.getLogger().setLevel(logging.DEBUG)
>>> logging.getLogger().disabled = False
>>> handler = logging.StreamHandler(sys.stdout) >>> handler = logging.StreamHandler(sys.stdout)
>>> logging.getLogger().addHandler(handler) >>> logging.getLogger().addHandler(handler)
...@@ -144,6 +146,7 @@ starting point, or just pick up where another iterator left off: ...@@ -144,6 +146,7 @@ starting point, or just pick up where another iterator left off:
>>> it.close() >>> it.close()
>>> logging.getLogger().setLevel(old_log_level) >>> logging.getLogger().setLevel(old_log_level)
>>> logging.getLogger().disabled = old_log_disabled
>>> logging.getLogger().removeHandler(handler) >>> logging.getLogger().removeHandler(handler)
......
...@@ -176,6 +176,8 @@ Make sure we can restore: ...@@ -176,6 +176,8 @@ Make sure we can restore:
>>> logger = logging.getLogger('ZODB.FileStorage') >>> logger = logging.getLogger('ZODB.FileStorage')
>>> logger.setLevel(logging.DEBUG) >>> logger.setLevel(logging.DEBUG)
>>> logger.addHandler(handler) >>> logger.addHandler(handler)
>>> log_disabled = logger.disabled
>>> logger.disabled = False
>>> index, pos, tid = fs._restore_index() >>> index, pos, tid = fs._restore_index()
>>> index.items() == fs._index.items() >>> index.items() == fs._index.items()
True True
...@@ -186,6 +188,7 @@ cleanup ...@@ -186,6 +188,7 @@ cleanup
>>> fs.close() >>> fs.close()
>>> logger.setLevel(logging.NOTSET) >>> logger.setLevel(logging.NOTSET)
>>> logger.removeHandler(handler) >>> logger.removeHandler(handler)
>>> logger.disabled = log_disabled
>>> sys.setrecursionlimit(old_limit) >>> sys.setrecursionlimit(old_limit)
""" """
......
...@@ -83,6 +83,7 @@ class Handler(logging.Handler): ...@@ -83,6 +83,7 @@ class Handler(logging.Handler):
def setLoggerLevel(self, level=1): def setLoggerLevel(self, level=1):
self.level = level self.level = level
self.oldlevels = {} self.oldlevels = {}
self.olddisabled = {}
def emit(self, record): def emit(self, record):
self.records.append(record) self.records.append(record)
...@@ -94,13 +95,16 @@ class Handler(logging.Handler): ...@@ -94,13 +95,16 @@ class Handler(logging.Handler):
for name in self.names: for name in self.names:
logger = logging.getLogger(name) logger = logging.getLogger(name)
self.oldlevels[name] = logger.level self.oldlevels[name] = logger.level
self.olddisabled[name] = logger.disabled
logger.setLevel(self.level) logger.setLevel(self.level)
logger.disabled = False
logger.addHandler(self) logger.addHandler(self)
def uninstall(self): def uninstall(self):
for name in self.names: for name in self.names:
logger = logging.getLogger(name) logger = logging.getLogger(name)
logger.setLevel(self.oldlevels[name]) logger.setLevel(self.oldlevels[name])
logger.disabled = self.olddisabled[name]
logger.removeHandler(self) logger.removeHandler(self)
def __str__(self): def __str__(self):
......
...@@ -379,6 +379,7 @@ def commit_from_wrong_partition(): ...@@ -379,6 +379,7 @@ def commit_from_wrong_partition():
>>> logger.propagate = False >>> logger.propagate = False
>>> logger.setLevel(logging.DEBUG) >>> logger.setLevel(logging.DEBUG)
>>> logger.addHandler(handler) >>> logger.addHandler(handler)
>>> logger.disabled = False
>>> blob_storage = create_storage() # noqa: F821 undefined name >>> blob_storage = create_storage() # noqa: F821 undefined name
>>> database = DB(blob_storage) >>> 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