summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoah <noah@656d521f-e311-0410-88e0-e7920216d269>2007-12-26 21:33:50 +0000
committernoah <noah@656d521f-e311-0410-88e0-e7920216d269>2007-12-26 21:33:50 +0000
commit2b7a7d857a88c43e796133c727e225e3f4ed748c (patch)
treefa5dd74d10ec2263c15fcd226025cf9a152d5d76
parentf7436e5fb8c5b237bd657b1457b6db01de08b096 (diff)
downloadpexpect-2b7a7d857a88c43e796133c727e225e3f4ed748c.tar.gz
I had to make a few tweaks to fix some broken tests. All tests pass at 82% code coverage.
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@505 656d521f-e311-0410-88e0-e7920216d269
-rw-r--r--pexpect/fdpexpect.py6
-rwxr-xr-xpexpect/tests/swapcase_echo.py3
-rwxr-xr-xpexpect/tests/test_filedescriptor.py2
-rwxr-xr-xpexpect/tests/test_interact.py7
4 files changed, 11 insertions, 7 deletions
diff --git a/pexpect/fdpexpect.py b/pexpect/fdpexpect.py
index 8797e43..90eb440 100644
--- a/pexpect/fdpexpect.py
+++ b/pexpect/fdpexpect.py
@@ -49,13 +49,13 @@ class fdspawn (spawn):
def close (self):
- if super(fdspawn, self).child_fd == -1:
+ if self.child_fd == -1:
return
if self.own_fd:
- super(fdspawn, self).close (self)
+ self.close (self)
else:
self.flush()
- os.close(super(fdspawn, self).child_fd)
+ os.close(self.child_fd)
self.child_fd = -1
self.closed = True
diff --git a/pexpect/tests/swapcase_echo.py b/pexpect/tests/swapcase_echo.py
index 03ee922..565254e 100755
--- a/pexpect/tests/swapcase_echo.py
+++ b/pexpect/tests/swapcase_echo.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
-import sys
+import sys, time
while True:
x = raw_input ()
+ time.sleep(1) # without this delay the test would fail about 75% of the time. Why?
print x.swapcase()
sys.stdout.flush()
diff --git a/pexpect/tests/test_filedescriptor.py b/pexpect/tests/test_filedescriptor.py
index 34e32d5..999d94e 100755
--- a/pexpect/tests/test_filedescriptor.py
+++ b/pexpect/tests/test_filedescriptor.py
@@ -38,7 +38,7 @@ class ExpectTestCase(PexpectTestCase.PexpectTestCase):
s = fdpexpect.fdspawn (fd)
assert not s.isatty()
#os.close(fd)
- fd.close(fd)
+ s.close()
### def test_close_does_not_close_fd (self):
### """Calling close() on a fdpexpect.fdspawn object should not
diff --git a/pexpect/tests/test_interact.py b/pexpect/tests/test_interact.py
index a74b9a2..f83d531 100755
--- a/pexpect/tests/test_interact.py
+++ b/pexpect/tests/test_interact.py
@@ -14,6 +14,8 @@ class InteractTestCase (PexpectTestCase.PexpectTestCase):
def test_interact_thread (self):
# I can't believe this actually works...
+ # Note that I had to add a delay in the swapcase_echo.py script.
+ # I'm not sure why this helped.
p = pexpect.spawn('%s swapcase_echo.py' % self.PYTHONBIN)
mode = tty.tcgetattr(p.STDIN_FILENO)
t = threading.Thread (target=start_interact, args=(p,))
@@ -21,12 +23,13 @@ class InteractTestCase (PexpectTestCase.PexpectTestCase):
#thread.start_new_thread (start_interact, (p,))
time.sleep(1)
p.sendline ('Hello')
- time.sleep(1)
+ #time.sleep(1)
try:
- p.expect ('olleH', timeout=5)
+ p.expect ('hELLO', timeout=4)
except Exception, e:
p.close(force = False)
tty.tcsetattr(p.STDIN_FILENO, tty.TCSAFLUSH, mode)
+ print str(p)
raise e
p.close(force = True)
tty.tcsetattr(p.STDIN_FILENO, tty.TCSAFLUSH, mode)