[Pyunit-interest] PyUnit hangs when I do the following absurdly complicated thing
Brought to you by:
purcell
From: Pat M. <jp...@cs...> - 2004-06-29 20:51:32
|
When I call a PyUnit program from a Java program on Windows XP, and the=20= PyUnit program trips an assertion, the Python program hangs. I don't=20 know what to try next. Anyone have any suggestions for how I could=20 learn more? I wrote a short Java program (attachment 1) that uses Runtime to run a=20= Python program. The specific call is: Process child =3D Runtime.getRuntime().exec ("python TripAssert.py",=20 null, workDir); The Python program (attachment 2) imports unittest and then creates a=20 test case. The test case has a single line, which is an assert. When I run the Python program from the command line, it always works,=20 whether the assert is true or false. In either case, I get what I=20 expect. When I run the Java program that runs the Python program, it will run=20 correctly if the assert is true (sample output 1). But, when the assert=20= is false, the program hangs (sample output 2). Sample output 3 shows=20 the output when the assert is false and the Python program is run=20 directly. I thought it might be running out of memory. I=92ve got 256 Mb. But, the=20= Task Manager says there=92s over 100 Mb available. I=92m pretty new to Windows programming (I=92m an old Unix programmer), = and=20 I don=92t know how to figure out what=92s happening. What tools might I = use=20 to try to find this? How can I find out what a process is waiting on?=20 Anyone seen anything like this? Versions: =95Python 2.3 =95PyUnit 1.4.1 =95Java j2sdk1.4.2_04 =95Windows XP Pro Version 5.1, Service Pack 1 --- Attachment 1: Java program ------- import java.io.File; import java.io.InputStream; public class TestCallPython { public static void main(String[] args) throws Exception { System.out.println ("TestCallPython\n"); File workDir =3D new File ("\\Documents and = settings\\a0868072\\my=20 documents\\work\\workspace\\TestCallPython"); Process child =3D Runtime.getRuntime().exec ("python = TripAssert.py",=20 null, workDir); displayOuts (child); } =09 public static void displayOuts (Process child) throws Exception = { System.out.println ("stdout"); InputStream in =3D child.getInputStream(); int c; while ((c =3D in.read()) !=3D -1) { System.out.print((char)c); } in.close(); System.out.println ("\nstderr"); =09 InputStream er =3D child.getErrorStream(); while ((c =3D er.read()) !=3D -1) { System.out.print((char)c); } er.close(); System.out.println ("end"); } } --- Attachment 2: Python program ------- import unittest class LoggingTestCase (unittest.TestCase): def test1Assert1 (self): #self.assertEqual (1, 2) self.assertEqual (1, 1) suite =3D unittest.makeSuite(LoggingTestCase,'test') if __name__ =3D=3D "__main__": unittest.main() --- Sample output 1: when assertEqual (1, 1) compiled in ------- C:\Documents and Settings\a0868072\My=20 Documents\work\workspace\TestCallPython>java TestCallPython TestCallPython stdout stderr . ---------------------------------------------------------------------- Ran 1 test in 0.000s OK end C:\Documents and Settings\a0868072\My=20 Documents\work\workspace\TestCallPython> --- Sample output 2: when assertEqual (1, 2) compiled in, from Java=20 ------- C:\Documents and Settings\a0868072\My=20 Documents\work\workspace\TestCallPython>java TestCallPython TestCallPython stdout {Note: I waited about 10 seconds, then hit ^C here.} C:\Documents and Settings\a0868072\My=20 Documents\work\workspace\TestCallPython> --- Sample output 3: when assertEqual (1, 2) compiled in, from Python=20 ------- C:\Documents and Settings\a0868072\My=20 Documents\work\workspace\TestCallPython>python TripAssert.py F =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D FAIL: test1Assert1 (__main__.LoggingTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "TripAssert.py", line 5, in test1Assert1 self.assertEqual (1, 2) File "c:\python23\lib\unittest.py", line 302, in failUnlessEqual raise self.failureException, \ AssertionError: 1 !=3D 2 ---------------------------------------------------------------------- Ran 1 test in 0.000s FAILED (failures=3D1) C:\Documents and Settings\a0868072\My=20 Documents\work\workspace\TestCallPython> --- Pat McGee Ph.D. Student, Computer Sciences Department, Florida Institute of=20 Technology Treasurer, Association for Software Testing, Inc.=20 (http://AssociationForSoftwareTesting.org) Editor, CS Department Tech Report Library (http://cs.fit.edu/~tr) jpm...@cs... http://blackbox.cs.fit.edu/blog/pat |