From 6fdfcec5b11f44f27aae3d53ddeb004150ae1f61 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Mon, 2 Nov 2020 19:25:29 +0000 Subject: =?UTF-8?q?bpo-41943:=20Fix=20bug=20where=20assertLogs=20doesn't?= =?UTF-8?q?=20correctly=20filter=20messages=E2=80=A6=20(GH-22565)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … by level @vsajip , @pitrou Automerge-Triggered-By: GH:vsajip --- Lib/unittest/test/test_case.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/unittest/test/test_case.py') 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) -- cgit v1.2.1