mirror of
https://github.com/python/cpython.git
synced 2025-07-30 22:54:16 +00:00
[3.13] gh-118868: logging QueueHandler fix passing of kwargs (GH-118869) (GH-120032)
(cherry picked from commit dce14bb2dc
)
This commit is contained in:
parent
6ce2810f36
commit
feaecf8c33
3 changed files with 39 additions and 8 deletions
|
@ -3976,6 +3976,35 @@ class ConfigDictTest(BaseTest):
|
|||
}
|
||||
logging.config.dictConfig(config)
|
||||
|
||||
# gh-118868: check if kwargs are passed to logging QueueHandler
|
||||
def test_kwargs_passing(self):
|
||||
class CustomQueueHandler(logging.handlers.QueueHandler):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(queue.Queue())
|
||||
self.custom_kwargs = kwargs
|
||||
|
||||
custom_kwargs = {'foo': 'bar'}
|
||||
|
||||
config = {
|
||||
'version': 1,
|
||||
'handlers': {
|
||||
'custom': {
|
||||
'class': CustomQueueHandler,
|
||||
**custom_kwargs
|
||||
},
|
||||
},
|
||||
'root': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['custom']
|
||||
}
|
||||
}
|
||||
|
||||
logging.config.dictConfig(config)
|
||||
|
||||
handler = logging.getHandlerByName('custom')
|
||||
self.assertEqual(handler.custom_kwargs, custom_kwargs)
|
||||
|
||||
|
||||
class ManagerTest(BaseTest):
|
||||
def test_manager_loggerclass(self):
|
||||
logged = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue