[Jython-checkins] jython: Tweak test_popen2 and test_cmd_line to own their Popen.__del__ failures.

jeff.allen jython-checkins at python.org
Sun Mar 2 21:24:46 CET 2014


http://hg.python.org/jython/rev/f238f769301a
changeset:   7190:f238f769301a
user:        Jeff Allen <ja.py at farowl.co.uk>
date:        Sat Mar 01 23:22:35 2014 +0000
summary:
  Tweak test_popen2 and test_cmd_line to own their Popen.__del__ failures.
Force GC to run during these tests so that failures they cause appear
during the tests, rather than randomly later.

files:
  Lib/test/test_cmd_line.py |   9 +++++++++
  Lib/test/test_popen2.py   |  10 +++++++++-
  2 files changed, 18 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -5,6 +5,15 @@
 import subprocess
 
 class CmdLineTest(unittest.TestCase):
+
+    @classmethod
+    def tearDownClass(cls):
+        if test.test_support.is_jython:
+            # GC is not immediate, so if Popen.__del__ may be delayed.
+            # Try to force any Popen.__del__ errors within scope of test.
+            from test_weakref import extra_collect
+            extra_collect()
+
     def start_python(self, cmd_line):
         outfp, infp = popen2.popen4('"%s" %s' % (sys.executable, cmd_line))
         infp.close()
diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py
--- a/Lib/test/test_popen2.py
+++ b/Lib/test/test_popen2.py
@@ -12,7 +12,7 @@
 import unittest
 import popen2
 
-from test.test_support import run_unittest, reap_children
+from test.test_support import run_unittest, reap_children, is_jython
 
 if sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos':
     #  Locks get messed up or something.  Generally we're supposed
@@ -59,6 +59,14 @@
         self.assertFalse(subprocess._active, "subprocess._active not empty")
         reap_children()
 
+    @classmethod
+    def tearDownClass(cls):
+        if is_jython:
+            # GC is not immediate, so if Popen.__del__ may be delayed.
+            # Try to force Popen.__del__ within scope of test.
+            from test_weakref import extra_collect
+            extra_collect()
+
     def validate_output(self, teststr, expected_out, r, w, e=None):
         w.write(teststr)
         w.close()

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list