summaryrefslogtreecommitdiff
path: root/Lib/test/test_pty.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_pty.py')
-rw-r--r--Lib/test/test_pty.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index c00244f10d..05ab598d98 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -1,10 +1,14 @@
+from test.test_support import verbose, run_unittest, import_module
+
+#Skip these tests if either fcntl or termios is not available
+fcntl = import_module('fcntl')
+import_module('termios')
+
import errno
-import fcntl
import pty
import os
import sys
import signal
-from test.test_support import verbose, TestSkipped, run_unittest
import unittest
TEST_STRING_1 = "I wish to buy a fish license.\n"
@@ -69,7 +73,7 @@ class PtyTest(unittest.TestCase):
debug("Got slave_fd '%d'" % slave_fd)
except OSError:
# " An optional feature could not be imported " ... ?
- raise TestSkipped, "Pseudo-terminals (seemingly) not functional."
+ raise unittest.SkipTest, "Pseudo-terminals (seemingly) not functional."
self.assertTrue(os.isatty(slave_fd), 'slave_fd is not a tty')
@@ -82,7 +86,7 @@ class PtyTest(unittest.TestCase):
fcntl.fcntl(master_fd, fcntl.F_SETFL, orig_flags | os.O_NONBLOCK)
try:
s1 = os.read(master_fd, 1024)
- self.assertEquals('', s1)
+ self.assertEqual('', s1)
except OSError, e:
if e.errno != errno.EAGAIN:
raise
@@ -92,14 +96,14 @@ class PtyTest(unittest.TestCase):
debug("Writing to slave_fd")
os.write(slave_fd, TEST_STRING_1)
s1 = os.read(master_fd, 1024)
- self.assertEquals('I wish to buy a fish license.\n',
- normalize_output(s1))
+ self.assertEqual('I wish to buy a fish license.\n',
+ normalize_output(s1))
debug("Writing chunked output")
os.write(slave_fd, TEST_STRING_2[:5])
os.write(slave_fd, TEST_STRING_2[5:])
s2 = os.read(master_fd, 1024)
- self.assertEquals('For my pet fish, Eric.\n', normalize_output(s2))
+ self.assertEqual('For my pet fish, Eric.\n', normalize_output(s2))
os.close(slave_fd)
os.close(master_fd)