summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2022-08-31 09:50:29 (GMT)
committerGitHub <noreply@github.com>2022-08-31 09:50:29 (GMT)
commit29f1b0bb1ff73dcc28f0ca7e11794141b6de58c9 (patch)
treedaf510cf627f7543a608ee60799fcf2a059d4660 /Lib/test/test_logging.py
parentf7e7bf161aaec5a5cffdcec7c97e1f09e445421b (diff)
downloadcpython-29f1b0bb1ff73dcc28f0ca7e11794141b6de58c9.zip
cpython-29f1b0bb1ff73dcc28f0ca7e11794141b6de58c9.tar.gz
cpython-29f1b0bb1ff73dcc28f0ca7e11794141b6de58c9.tar.bz2
gh-89258: Add a getChildren() method to logging.Logger. (GH-96444)
Co-authored-by: Éric <merwok@netwok.org>
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index a67ed07..0c852fc1 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -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