summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pty.py
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-04-21 10:40:58 (GMT)
committerThomas Wouters <thomas@python.org>2006-04-21 10:40:58 (GMT)
commit49fd7fa4431da299196d74087df4a04f99f9c46f (patch)
tree35ace5fe78d3d52c7a9ab356ab9f6dbf8d4b71f4 /Lib/test/test_pty.py
parent9ada3d6e29d5165dadacbe6be07bcd35cfbef59d (diff)
downloadcpython-49fd7fa4431da299196d74087df4a04f99f9c46f.zip
cpython-49fd7fa4431da299196d74087df4a04f99f9c46f.tar.gz
cpython-49fd7fa4431da299196d74087df4a04f99f9c46f.tar.bz2
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
number of tests, all because of the codecs/_multibytecodecs issue described here (it's not a Py3K issue, just something Py3K discovers): http://mail.python.org/pipermail/python-dev/2006-April/064051.html Hye-Shik Chang promised to look for a fix, so no need to fix it here. The tests that are expected to break are: test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecs test_multibytecodec This merge fixes an actual test failure (test_weakref) in this branch, though, so I believe merging is the right thing to do anyway.
Diffstat (limited to 'Lib/test/test_pty.py')
-rw-r--r--Lib/test/test_pty.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index f8ae479..99e01b6 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -18,6 +18,27 @@ else:
def debug(msg):
pass
+def normalize_output(data):
+ # Some operating systems do conversions on newline. We could possibly
+ # fix that by doing the appropriate termios.tcsetattr()s. I couldn't
+ # figure out the right combo on Tru64 and I don't have an IRIX box.
+ # So just normalize the output and doc the problem O/Ses by allowing
+ # certain combinations for some platforms, but avoid allowing other
+ # differences (like extra whitespace, trailing garbage, etc.)
+
+ # This is about the best we can do without getting some feedback
+ # from someone more knowledgable.
+
+ # OSF/1 (Tru64) apparently turns \n into \r\r\n.
+ if data.endswith('\r\r\n'):
+ return data[:-3] + '\n'
+
+ # IRIX apparently turns \n into \r\n.
+ if data.endswith('\r\n'):
+ return data[:-2] + '\n'
+
+ return data
+
# Marginal testing of pty suite. Cannot do extensive 'do or fail' testing
# because pty code is not too portable.
@@ -36,19 +57,16 @@ def test_basic_pty():
if not os.isatty(slave_fd) and sys.platform not in fickle_isatty:
raise TestFailed, "slave_fd is not a tty"
- # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other
- # differences (like extra whitespace, trailing garbage, etc.)
-
debug("Writing to slave_fd")
os.write(slave_fd, TEST_STRING_1)
s1 = os.read(master_fd, 1024)
- sys.stdout.write(s1.replace("\r\n", "\n"))
+ sys.stdout.write(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)
- sys.stdout.write(s2.replace("\r\n", "\n"))
+ sys.stdout.write(normalize_output(s2))
os.close(slave_fd)
os.close(master_fd)