test_poll: fix "ResourceWarning: unclosed file"
authorZac Medico <zmedico@gentoo.org>
Mon, 29 Aug 2011 03:59:26 +0000 (20:59 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 29 Aug 2011 03:59:26 +0000 (20:59 -0700)
pym/portage/tests/process/test_poll.py

index ee6ee0c3fb5a92f8fe68693fe5a96c1397077db6..c3b50d4bee88838b18148e1ab0b86f60e4453e29 100644 (file)
@@ -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)