Skip to content

Commit

Permalink
only SkipTest on IOError on setecho & friends for sunos
Browse files Browse the repository at this point in the history
  • Loading branch information
jquast committed Jun 3, 2014
1 parent d7247a0 commit 6529f7a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 22 deletions.
32 changes: 20 additions & 12 deletions tests/test_expect.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
'''
from __future__ import with_statement # bring 'with' stmt to py25
import pexpect
import unittest
import subprocess
import time
import PexpectTestCase
import signal
import sys

import pexpect
import PexpectTestCase

# Many of these test cases blindly assume that sequential directory
# listings of the /bin directory will yield the same results.
Expand Down Expand Up @@ -192,9 +194,12 @@ def test_waitnoecho (self):
try:
p1.waitnoecho(timeout=10)
except IOError:
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
if sys.platform.lower().startswith('sunos'):
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
raise

end_time = time.time() - start
assert end_time < 10 and end_time > 2, "waitnoecho did not set ECHO off in the expected window of time."

Expand Down Expand Up @@ -226,9 +231,10 @@ def test_expect_setecho_off(self):
try:
self._expect_echo_toggle(p)
except IOError:
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
if sys.platform.lower().startswith('sunos'):
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'

def test_expect_echo_exact (self):
'''Like test_expect_echo(), but using expect_exact().
Expand All @@ -243,9 +249,11 @@ def test_expect_setecho_off_exact(self):
try:
self._expect_echo_toggle(p)
except IOError:
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
if sys.platform.lower().startswith('sunos'):
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
raise

def _expect_echo (self, p):
p.sendline (b'1234') # Should see this twice (once from tty echo and again from cat).
Expand Down Expand Up @@ -486,7 +494,7 @@ def _greed_read1(self, expect):
# Here, one has an earlier start and a later end. When processing
# one character at a time, the one that finishes first should win,
# because we don't know about the other match when it wins.
# If maxread > 1, this behavior is currently undefined, although in
# If maxread > 1, this behaviour is currently undefined, although in
# most cases the one that starts first will win.
self.assertEqual(expect([b'1, 2, 3', b'2,']), 1)

Expand Down
11 changes: 7 additions & 4 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import pexpect
import unittest
import PexpectTestCase
import os, sys
import os
import sys
import re
import signal
import time
Expand All @@ -35,9 +36,11 @@ def test_isatty (self):
child = pexpect.spawn('cat')
val = child.isatty()
if not val and sys.platform.lower().startswith('sunos'):
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
if sys.platform.lower().startswith('sunos'):
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
raise
assert child.isatty(), "Not returning True. Should always be True."

def test_read (self):
Expand Down
17 changes: 11 additions & 6 deletions tests/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import platform
import tempfile
import sys

import pexpect
import unittest
Expand Down Expand Up @@ -47,9 +48,11 @@ def test_expect_setecho_off(self):
try:
self._expect_echo_toggle(p)
except IOError:
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
if sys.platform.lower().startswith('sunos'):
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
raise

def test_expect_echo_exact (self):
'''Like test_expect_echo(), but using expect_exact().
Expand All @@ -64,9 +67,11 @@ def test_expect_setecho_off_exact(self):
try:
self._expect_echo_toggle(p)
except IOError:
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
if sys.platform.lower().startswith('sunos'):
if hasattr(unittest, 'SkipTest'):
raise unittest.SkipTest("Not supported on this platform.")
return 'skip'
raise

def _expect_echo (self, p):
p.sendline('1234') # Should see this twice (once from tty echo and again from cat).
Expand Down

0 comments on commit 6529f7a

Please sign in to comment.