diff options
author | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2003-01-06 07:20:00 +0000 |
---|---|---|
committer | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2003-01-06 07:20:00 +0000 |
commit | 1d751669edd6a3755bcf3f13d3e9edd727d3b805 (patch) | |
tree | d172df7a0e118a8b29837af0949e05b80baf3fd1 | |
parent | 421eea3fbd55504af1221d76095a35a680ccf50b (diff) | |
download | pexpect-1d751669edd6a3755bcf3f13d3e9edd727d3b805.tar.gz |
Fixed tests on Solaris. I think isalive() finally works on Solaris.
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@136 656d521f-e311-0410-88e0-e7920216d269
-rw-r--r-- | pexpect/pexpect.py | 4 | ||||
-rwxr-xr-x | pexpect/tests/test_destructor.py | 28 | ||||
-rwxr-xr-x | pexpect/tests/test_isalive.py | 10 |
3 files changed, 35 insertions, 7 deletions
diff --git a/pexpect/pexpect.py b/pexpect/pexpect.py index a2abbea..0d58074 100644 --- a/pexpect/pexpect.py +++ b/pexpect/pexpect.py @@ -24,6 +24,7 @@ $Date$ import os, sys import select import traceback +import string import re import struct import resource @@ -658,7 +659,8 @@ def which (filename): else: p = os.environ['PATH'] - pathlist = p.split (os.pathsep) + #pathlist = p.split (os.pathsep) + pathlist = string.split (p, os.pathsep) for path in pathlist: f = os.path.join(path, filename) diff --git a/pexpect/tests/test_destructor.py b/pexpect/tests/test_destructor.py index c676635..cca4a67 100755 --- a/pexpect/tests/test_destructor.py +++ b/pexpect/tests/test_destructor.py @@ -18,39 +18,57 @@ class TestCaseDestructor(unittest.TestCase): p3.expect(pexpect.EOF) p4.expect(pexpect.EOF) #print p1.before, p2.before, p3.before, p4.before - #print fd_t1 + print fd_t1 p1.kill(9) p2.kill(9) p3.kill(9) p4.kill(9) + time.sleep(1) # Some platforms are slow at gc... Solaris! + p1.close() + p2.close() + p3.close() + p4.close() + p1.isalive() + p2.isalive() + p3.isalive() + p4.isalive() p1 = None p2 = None p3 = None p4 = None gc.collect() - time.sleep(2) # Some platforms are slow at gc... Solaris! + time.sleep(1) # Some platforms are slow at gc... Solaris! p1 = pexpect.spawn('ls -l') p2 = pexpect.spawn('ls -l') p3 = pexpect.spawn('ls -l') p4 = pexpect.spawn('ls -l') fd_t2 = (p1.child_fd,p2.child_fd,p3.child_fd,p4.child_fd) - # print fd_t2 + print fd_t2 p1.kill(9) p2.kill(9) p3.kill(9) p4.kill(9) + time.sleep(1) # Some platforms are slow at gc... Solaris! + p1.close() + p2.close() + p3.close() + p4.close() + p1.isalive() + p2.isalive() + p3.isalive() + p4.isalive() del (p1) del (p2) del (p3) del (p4) gc.collect() - time.sleep(3) # Some platforms are slow at gc... Solaris! + time.sleep(1) # Some platforms are slow at gc... Solaris! p1 = pexpect.spawn('ls -l') p2 = pexpect.spawn('ls -l') p3 = pexpect.spawn('ls -l') p4 = pexpect.spawn('ls -l') fd_t3 = (p1.child_fd,p2.child_fd,p3.child_fd,p4.child_fd) - # print fd_t3 + print fd_t3 assert (fd_t1 == fd_t2 == fd_t3) diff --git a/pexpect/tests/test_isalive.py b/pexpect/tests/test_isalive.py index 3320e44..5b7e91b 100755 --- a/pexpect/tests/test_isalive.py +++ b/pexpect/tests/test_isalive.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import pexpect import unittest -import sys, os +import sys, os, time class IsAliveTestCase(unittest.TestCase): @@ -16,6 +16,10 @@ class IsAliveTestCase(unittest.TestCase): if not p.isalive(): self.fail ('Child process is not alive. It should be.') p.kill(1) + # Solaris is kind of slow. + # Without this delay then p.expect(...) will not see + # that the process is dead and it will timeout. + time.sleep(1) p.expect(pexpect.EOF) if p.isalive(): self.fail ('Child process is not dead. It should be.') @@ -25,6 +29,10 @@ class IsAliveTestCase(unittest.TestCase): if not p.isalive(): self.fail ('Child process is not alive. It should be.') p.kill(9) + # Solaris is kind of slow. + # Without this delay then p.expect(...) will not see + # that the process is dead and it will timeout. + time.sleep(1) p.expect(pexpect.EOF) if p.isalive(): # pid, sts = os.waitpid(p.pid, 0)#, os.WNOHANG) |