From b76d113b6c23fdcb4dcbf8084e7e3773448d0ff5 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 28 Aug 2011 20:59:26 -0700 Subject: [PATCH] test_poll: fix "ResourceWarning: unclosed file" --- pym/portage/tests/process/test_poll.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pym/portage/tests/process/test_poll.py b/pym/portage/tests/process/test_poll.py index ee6ee0c3f..c3b50d4be 100644 --- a/pym/portage/tests/process/test_poll.py +++ b/pym/portage/tests/process/test_poll.py @@ -34,6 +34,14 @@ class PipeReaderTestCase(TestCase): scheduler=scheduler) consumer.start() - consumer.wait() + + # This will ensure that both tasks have exited, which + # is necessary to avoid "ResourceWarning: unclosed file" + # warnings since Python 3.2 (and also ensures that we + # don't leave any zombie child processes). + scheduler.schedule() + self.assertEqual(producer.returncode, os.EX_OK) + self.assertEqual(consumer.returncode, os.EX_OK) + output = consumer.getvalue().decode('ascii', 'replace') self.assertEqual(test_string, output) -- 2.26.2