mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-08-27 06:14:21 +03:00
[test:networking] Fix logging handler removal test (#17379)
Ref: https://github.com/python/cpython/issues/79366 Authored by: doe1080
This commit is contained in:
@@ -859,15 +859,15 @@ class TestRequestHandlerMisc:
|
|||||||
('Websockets', 'websockets.server'),
|
('Websockets', 'websockets.server'),
|
||||||
], indirect=['handler'])
|
], indirect=['handler'])
|
||||||
def test_remove_logging_handler(self, handler, logger_name):
|
def test_remove_logging_handler(self, handler, logger_name):
|
||||||
# Ensure any logging handlers, which may contain a YoutubeDL instance,
|
# Ensure closing the request handler removes only its logging handlers,
|
||||||
# are removed when we close the request handler
|
# which may reference a YoutubeDL instance
|
||||||
# See: https://github.com/yt-dlp/yt-dlp/issues/8922
|
# See: https://github.com/yt-dlp/yt-dlp/issues/8922
|
||||||
logging_handlers = logging.getLogger(logger_name).handlers
|
logger = logging.getLogger(logger_name)
|
||||||
before_count = len(logging_handlers)
|
original_handlers = logger.handlers.copy()
|
||||||
rh = handler()
|
rh = handler()
|
||||||
assert len(logging_handlers) == before_count + 1
|
assert len(logger.handlers) == len(original_handlers) + 1
|
||||||
rh.close()
|
rh.close()
|
||||||
assert len(logging_handlers) == before_count
|
assert logger.handlers == original_handlers
|
||||||
|
|
||||||
def test_wrap_request_errors(self):
|
def test_wrap_request_errors(self):
|
||||||
class TestRequestHandler(RequestHandler):
|
class TestRequestHandler(RequestHandler):
|
||||||
|
|||||||
Reference in New Issue
Block a user