mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-89258: Add a getChildren() method to logging.Logger. (GH-96444)
Co-authored-by: Éric <merwok@netwok.org>
This commit is contained in:
parent
f7e7bf161a
commit
29f1b0bb1f
4 changed files with 47 additions and 0 deletions
|
@ -3717,6 +3717,20 @@ class ChildLoggerTest(BaseTest):
|
|||
self.assertIs(c2, logging.getLogger('abc.def.ghi'))
|
||||
self.assertIs(c2, c3)
|
||||
|
||||
def test_get_children(self):
|
||||
r = logging.getLogger()
|
||||
l1 = logging.getLogger('foo')
|
||||
l2 = logging.getLogger('foo.bar')
|
||||
l3 = logging.getLogger('foo.bar.baz.bozz')
|
||||
l4 = logging.getLogger('bar')
|
||||
kids = r.getChildren()
|
||||
expected = {l1, l4}
|
||||
self.assertEqual(expected, kids & expected) # might be other kids for root
|
||||
self.assertNotIn(l2, expected)
|
||||
kids = l1.getChildren()
|
||||
self.assertEqual({l2}, kids)
|
||||
kids = l2.getChildren()
|
||||
self.assertEqual(set(), kids)
|
||||
|
||||
class DerivedLogRecord(logging.LogRecord):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue