diff options
| author | Jeff Quast <contact@jeffquast.com> | 2014-06-08 08:07:03 +0000 |
|---|---|---|
| committer | Thomas Kluyver <takowl@gmail.com> | 2014-06-15 18:43:30 -0700 |
| commit | 8f48ac8d97ffd520074f02af4ef5ef7b8aadf862 (patch) | |
| tree | 9ef92a067a651e6487a95d167f20056aeb977c38 /tests/test_misc.py | |
| parent | 9716ea092af443f706c40ce409219b6f7c714013 (diff) | |
| download | pexpect-8f48ac8d97ffd520074f02af4ef5ef7b8aadf862.tar.gz | |
Solaris support, tested on SmartOS from cron(1).
Diffstat (limited to 'tests/test_misc.py')
| -rwxr-xr-x | tests/test_misc.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/tests/test_misc.py b/tests/test_misc.py index a052fe5..cb82a09 100755 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -25,6 +25,7 @@ import sys import re import signal import time +import os # the program cat(1) may display ^D\x08\x08 when \x04 (EOF, Ctrl-D) is sent _CAT_EOF = b'^D\x08\x08' @@ -33,7 +34,11 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase): def test_isatty (self): child = pexpect.spawn('cat') - assert child.isatty(), "Not returning True. Should always be True." + if not child.isatty() and sys.platform.lower().startswith('sunos'): + if hasattr(unittest, 'SkipTest'): + raise unittest.SkipTest("Not supported on this platform.") + return 'skip' + assert child.isatty() def test_read (self): child = pexpect.spawn('cat') @@ -102,7 +107,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase): assert (page == b'abc\r\nabc\r\n123\r\n123\r\n' or page == b'abc\r\n123\r\nabc\r\n123\r\n' or page == b'abc\r\n123abc\r\n\r\n123\r\n') , \ - "iterator did not work. page=%r"(page,) + "iterator did not work. page=%r" % (page,) def test_readlines(self): '''Note that on some slow or heavily loaded systems that the lines @@ -208,34 +213,28 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase): else: self.fail ("child.isalive() should have raised a pexpect.ExceptionPexpect") child.terminated = 1 # Force back to valid state so __del__ won't complain + def test_bad_arguments (self): '''This tests that we get a graceful error when passing bad arguments.''' - try: - p = pexpect.spawn(1) - except pexpect.ExceptionPexpect: - pass - else: - self.fail ("pexpect.spawn(1) should have raised a pexpect.ExceptionPexpect.") - try: - p = pexpect.spawn('ls', '-la') # should really use pexpect.spawn('ls', ['-ls']) - except TypeError: - pass - else: - self.fail ("pexpect.spawn('ls', '-la') should have raised a TypeError.") - try: - p = pexpect.spawn('cat') + with self.assertRaises(pexpect.ExceptionPexpect): + pexpect.spawn(1) + + with self.assertRaises(TypeError): + # should use pexpect.spawn('ls', ['-ls']) + pexpect.spawn('ls', '-la') + + with self.assertRaises(ValueError): + p = pexpect.spawn('cat', timeout=5) p.close() p.read_nonblocking(size=1, timeout=3) - except ValueError: - pass - else: - self.fail ("read_nonblocking on closed spawn object should have raised a ValueError.") + def test_isalive(self): child = pexpect.spawn('cat') assert child.isalive(), child.isalive() child.sendeof() child.expect(pexpect.EOF) assert not child.isalive(), child.isalive() + def test_bad_type_in_expect(self): child = pexpect.spawn('cat') try: |
