https://github.com/python/cpython/commit/744129db5d4e7706fd7d46dfc691aa47fabd66fa commit: 744129db5d4e7706fd7d46dfc691aa47fabd66fa branch: 3.7 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: Victor Stinner <vstinner at redhat.com> date: 2019年05月13日T17:39:50+02:00 summary: bpo-36903: Fix ResourceWarning in test_logging (GH-13283) (GH-13285) (cherry picked from commit 2c10538d11fa9be9a1a9f21605861e10ec4fa207) Co-authored-by: Xtreak <tir.karthi at gmail.com> files: M Lib/test/test_logging.py diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 42746d40d2cd..14277369be47 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -689,6 +689,7 @@ def emit(self, record): self.assertEqual(len(logging._handlers), 0) refed_h = _OurHandler() + self.addCleanup(refed_h.sub_handler.stream.close) refed_h.name = 'because we need at least one for this test' self.assertGreater(len(logging._handlers), 0) self.assertGreater(len(logging._at_fork_reinit_lock_weakset), 1)