diff options
author | Thomas Kluyver <takowl@gmail.com> | 2014-06-04 17:45:37 -0700 |
---|---|---|
committer | Thomas Kluyver <takowl@gmail.com> | 2014-06-04 17:45:37 -0700 |
commit | a07835752f31ed3e3ae7336026c4846a0733209e (patch) | |
tree | 3660d407a34bee01a3f370d49cf5cfdd2e467017 | |
parent | a3047f5d480772fbbf771d9906e94984a103a48c (diff) | |
download | pexpect-a07835752f31ed3e3ae7336026c4846a0733209e.tar.gz |
Some more test coverage for fdpexpect
-rw-r--r-- | pexpect/fdpexpect.py | 4 | ||||
-rwxr-xr-x | tests/test_filedescriptor.py | 26 |
2 files changed, 9 insertions, 21 deletions
diff --git a/pexpect/fdpexpect.py b/pexpect/fdpexpect.py index 8a0da4a..fe4ad89 100644 --- a/pexpect/fdpexpect.py +++ b/pexpect/fdpexpect.py @@ -89,9 +89,9 @@ class fdspawn (spawn): except: return False - def terminate (self, force=False): + def terminate (self, force=False): # pragma: no cover raise ExceptionPexpect('This method is not valid for file descriptors.') - def kill (self, sig): + def kill (self, sig): # pragma: no cover """No-op - no process to kill.""" return diff --git a/tests/test_filedescriptor.py b/tests/test_filedescriptor.py index ac391b5..d9164e1 100755 --- a/tests/test_filedescriptor.py +++ b/tests/test_filedescriptor.py @@ -56,29 +56,17 @@ class ExpectTestCase(PexpectTestCase.PexpectTestCase): fd = os.open ('TESTDATA.txt', os.O_RDONLY) s = fdpexpect.fdspawn (fd) assert not s.isatty() - #os.close(fd) s.close() -### def test_close_does_not_close_fd (self): -### '''Calling close() on a fdpexpect.fdspawn object should not -### close the underlying file descriptor. -### ''' -### fd = os.open ('TESTDATA.txt', os.O_RDONLY) -### s = fdpexpect.fdspawn (fd) -### try: -### s.close() -### self.fail('Expected an Exception.') -### except pexpect.ExceptionPexpect, e: -### pass + def test_fileobj(self): + f = open('TESTDATA.txt', 'r') + s = fdpexpect.fdspawn(f) # Should get the fileno from the file handle + s.expect('2') + s.close() + assert not s.isalive() + s.close() # Smoketest - should be able to call this again if __name__ == '__main__': unittest.main() suite = unittest.makeSuite(ExpectTestCase, 'test') - -#fout = open('delete_me_1','wb') -#fout.write(the_old_way) -#fout.close -#fout = open('delete_me_2', 'wb') -#fout.write(the_new_way) -#fout.close |