[Python-checkins] r80058 - in python/branches/py3k-issue4970/Lib/test: regrtest.py test_issue4970.py test_os.py test_wait3.py

mark.dickinson python-checkins at python.org
Tue Apr 13 17:47:38 CEST 2010


Author: mark.dickinson
Date: Tue Apr 13 17:47:38 2010
New Revision: 80058

Log:
Give failing test its own name; restore old tests; output signal information.

Added:
   python/branches/py3k-issue4970/Lib/test/test_issue4970.py
Modified:
   python/branches/py3k-issue4970/Lib/test/regrtest.py
   python/branches/py3k-issue4970/Lib/test/test_os.py
   python/branches/py3k-issue4970/Lib/test/test_wait3.py

Modified: python/branches/py3k-issue4970/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k-issue4970/Lib/test/regrtest.py	(original)
+++ python/branches/py3k-issue4970/Lib/test/regrtest.py	Tue Apr 13 17:47:38 2010
@@ -260,8 +260,8 @@
              'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=',
              'multiprocess=', 'slaveargs=', 'forever', 'debug', 'start=',
              'nowindows'])
-        # Issue #4970: pretend that the only non-option arg was test_wait3
-        args = ['test_wait3']
+        # Issue #4970: pretend that the only non-option arg was test_issue4970
+        args = ['test_issue4970']
     except getopt.error as msg:
         usage(msg)
 

Added: python/branches/py3k-issue4970/Lib/test/test_issue4970.py
==============================================================================
--- (empty file)
+++ python/branches/py3k-issue4970/Lib/test/test_issue4970.py	Tue Apr 13 17:47:38 2010
@@ -0,0 +1,21 @@
+# Code demonstrating 'Unknown signal 32' failure on Gentoo
+# x86 buildbot.  See http://bugs.python.org/issue4970.
+
+# Output signals, to find out which one signal 32 is.
+import signal
+from pprint import pprint
+pprint(signal.__dict__)
+
+import os
+import time
+import _thread
+
+try:
+    os.execv('/usr/bin/dorothyq', ['dorothyq'])
+except OSError:
+    pass
+
+def f():
+    time.sleep(1.0)
+
+_thread.start_new(f, ())

Modified: python/branches/py3k-issue4970/Lib/test/test_os.py
==============================================================================
--- python/branches/py3k-issue4970/Lib/test/test_os.py	(original)
+++ python/branches/py3k-issue4970/Lib/test/test_os.py	Tue Apr 13 17:47:38 2010
@@ -589,12 +589,9 @@
 
 class ExecTests(unittest.TestCase):
     def test_execvpe_with_bad_program(self):
-        try:
-            os.execv('/usr/bin/dorothyq', ['dorothyq'])
-        except OSError:
-            pass
+        self.assertRaises(OSError, os.execvpe, 'no such app-', ['no such app-'], None)
 
-    def XXXtest_execvpe_with_bad_arglist(self):
+    def test_execvpe_with_bad_arglist(self):
         self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)
 
 class ArgTests(unittest.TestCase):
@@ -862,20 +859,20 @@
 
 def test_main():
     support.run_unittest(
-        #ArgTests,
-        #FileTests,
-        #StatAttributeTests,
-        #EnvironTests,
-        #WalkTests,
-        #MakedirTests,
-        #DevNullTests,
-        #URandomTests,
+        ArgTests,
+        FileTests,
+        StatAttributeTests,
+        EnvironTests,
+        WalkTests,
+        MakedirTests,
+        DevNullTests,
+        URandomTests,
         ExecTests,
-        #Win32ErrorTests,
-        #TestInvalidFD,
-        #PosixUidGidTests,
-        #Pep383Tests,
-        #Win32KillTests
+        Win32ErrorTests,
+        TestInvalidFD,
+        PosixUidGidTests,
+        Pep383Tests,
+        Win32KillTests
     )
 
 if __name__ == "__main__":

Modified: python/branches/py3k-issue4970/Lib/test/test_wait3.py
==============================================================================
--- python/branches/py3k-issue4970/Lib/test/test_wait3.py	(original)
+++ python/branches/py3k-issue4970/Lib/test/test_wait3.py	Tue Apr 13 17:47:38 2010
@@ -3,14 +3,37 @@
 
 import os
 import time
-import _thread
+import unittest
+from test.fork_wait import ForkWait
+from test.support import run_unittest, reap_children
 
 try:
-    os.execv('/usr/bin/dorothyq', ['dorothyq'])
-except OSError:
-    pass
+    os.fork
+except AttributeError:
+    raise unittest.SkipTest("os.fork not defined -- skipping test_wait3")
 
-def f():
-    time.sleep(1.0)
+try:
+    os.wait3
+except AttributeError:
+    raise unittest.SkipTest("os.wait3 not defined -- skipping test_wait3")
+
+class Wait3Test(ForkWait):
+    def wait_impl(self, cpid):
+        for i in range(10):
+            # wait3() shouldn't hang, but some of the buildbots seem to hang
+            # in the forking tests.  This is an attempt to fix the problem.
+            spid, status, rusage = os.wait3(os.WNOHANG)
+            if spid == cpid:
+                break
+            time.sleep(1.0)
+
+        self.assertEqual(spid, cpid)
+        self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
+        self.assertTrue(rusage)
+
+def test_main():
+    run_unittest(Wait3Test)
+    reap_children()
 
-_thread.start_new(f, ())
+if __name__ == "__main__":
+    test_main()


More information about the Python-checkins mailing list