[Python-checkins] bpo-36903: Fix ResourceWarning in test_logging (GH-13283)

Victor Stinner webhook-mailer at python.org
Mon May 13 10:48:56 EDT 2019


https://github.com/python/cpython/commit/2c10538d11fa9be9a1a9f21605861e10ec4fa207
commit: 2c10538d11fa9be9a1a9f21605861e10ec4fa207
branch: master
author: Xtreak <tir.karthi at gmail.com>
committer: Victor Stinner <vstinner at redhat.com>
date: 2019-05-13T16:48:51+02:00
summary:

bpo-36903: Fix ResourceWarning in test_logging (GH-13283)

files:
M Lib/test/test_logging.py

diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index bc99c3adbe34..b884753ad397 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -684,6 +684,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)



More information about the Python-checkins mailing list