mirror of
https://github.com/borgbackup/borg.git
synced 2026-07-08 01:31:04 -04:00
Merge pull request #9867 from ThomasWaldmann/fix-testsuite-logger-leak-1.4
Some checks are pending
CI / lint (push) Waiting to run
CI / asan_ubsan (push) Blocked by required conditions
CI / native_tests (push) Blocked by required conditions
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Blocked by required conditions
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Blocked by required conditions
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Blocked by required conditions
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Blocked by required conditions
CodeQL / Analyze (push) Waiting to run
Windows CI / msys2-ucrt64 (push) Waiting to run
Some checks are pending
CI / lint (push) Waiting to run
CI / asan_ubsan (push) Blocked by required conditions
CI / native_tests (push) Blocked by required conditions
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Blocked by required conditions
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Blocked by required conditions
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Blocked by required conditions
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Blocked by required conditions
CodeQL / Analyze (push) Waiting to run
Windows CI / msys2-ucrt64 (push) Waiting to run
testsuite: fix logger state leak in RemoteLoggerTestCase
This commit is contained in:
commit
a7aeef657d
1 changed files with 13 additions and 0 deletions
|
|
@ -1061,6 +1061,13 @@ class RemoteLoggerTestCase(BaseTestCase):
|
|||
def setUp(self):
|
||||
self.stream = io.StringIO()
|
||||
self.handler = logging.StreamHandler(self.stream)
|
||||
|
||||
# Save old logging state
|
||||
self.old_root_handlers = logging.getLogger().handlers[:]
|
||||
self.old_root_level = logging.getLogger().level
|
||||
self.old_repo_handlers = logging.getLogger('borg.repository').handlers[:]
|
||||
self.old_repo_level = logging.getLogger('borg.repository').level
|
||||
|
||||
logging.getLogger().handlers[:] = [self.handler]
|
||||
logging.getLogger('borg.repository').handlers[:] = []
|
||||
logging.getLogger('borg.repository.foo').handlers[:] = []
|
||||
|
|
@ -1071,6 +1078,12 @@ class RemoteLoggerTestCase(BaseTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
sys.stderr = self.old_stderr
|
||||
|
||||
# Restore old logging state
|
||||
logging.getLogger().handlers[:] = self.old_root_handlers
|
||||
logging.getLogger().setLevel(self.old_root_level)
|
||||
logging.getLogger('borg.repository').handlers[:] = self.old_repo_handlers
|
||||
logging.getLogger('borg.repository').setLevel(self.old_repo_level)
|
||||
|
||||
def test_stderr_messages(self):
|
||||
handle_remote_line("unstructured stderr message\n")
|
||||
|
|
|
|||
Loading…
Reference in a new issue