diff options
author | Irit Katriel <iritkatriel@yahoo.com> | 2020-11-02 19:25:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 11:25:29 -0800 |
commit | 6fdfcec5b11f44f27aae3d53ddeb004150ae1f61 (patch) | |
tree | e9e669365f26bd39003be9b4e698959eb413881d /Lib/unittest/test/test_case.py | |
parent | aca67da4fe68d5420401ac1782203d302875eb27 (diff) | |
download | cpython-git-6fdfcec5b11f44f27aae3d53ddeb004150ae1f61.tar.gz |
bpo-41943: Fix bug where assertLogs doesn't correctly filter messages… (GH-22565)
… by level
@vsajip , @pitrou
Automerge-Triggered-By: GH:vsajip
Diffstat (limited to 'Lib/unittest/test/test_case.py')
-rw-r--r-- | Lib/unittest/test/test_case.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py index 0e416967a3..b8aca92a8e 100644 --- a/Lib/unittest/test/test_case.py +++ b/Lib/unittest/test/test_case.py @@ -1673,6 +1673,18 @@ test case with self.assertLogs(level='WARNING'): log_foo.info("1") + def testAssertLogsFailureLevelTooHigh_FilterInRootLogger(self): + # Failure due to level too high - message propagated to root + with self.assertNoStderr(): + oldLevel = log_foo.level + log_foo.setLevel(logging.INFO) + try: + with self.assertRaises(self.failureException): + with self.assertLogs(level='WARNING'): + log_foo.info("1") + finally: + log_foo.setLevel(oldLevel) + def testAssertLogsFailureMismatchingLogger(self): # Failure due to mismatching logger (and the logged message is # passed through) |