diff options
| author | jquast <contact@jeffquast.com> | 2013-09-22 09:17:39 -0400 |
|---|---|---|
| committer | jquast <contact@jeffquast.com> | 2013-09-22 09:17:39 -0400 |
| commit | 09c2dd7900b34712cea1607bcda5d8f98e67923c (patch) | |
| tree | c42fe0d49dc0fb6259fa338f93d09b3c9f3185da /tests/test_misc.py | |
| parent | e1eeefafd206b7d13b25f64bfb00f5d944690723 (diff) | |
| download | pexpect-09c2dd7900b34712cea1607bcda5d8f98e67923c.tar.gz | |
cat(1) may display ^D\x08\x08 when ^D is used.
This causes various tests, that depend on cat(1) to fail on Mac OSX 10.8.5. These changes ensure that if ^D\x08\x08 ('^D', followed by '\b\b') is found, it is removed.
Diffstat (limited to 'tests/test_misc.py')
| -rwxr-xr-x | tests/test_misc.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test_misc.py b/tests/test_misc.py index 06cd068..467b739 100755 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -24,6 +24,9 @@ import PexpectTestCase import os import re +# the program cat(1) may display ^D\x08\x08 when \x04 (EOF, Ctrl-D) is sent +_CAT_EOF = b'^D\x08\x08' + class TestCaseMisc(PexpectTestCase.PexpectTestCase): def test_isatty (self): @@ -39,7 +42,10 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase): self.assertEqual(child.read(1), b'b') self.assertEqual(child.read(1), b'c') self.assertEqual(child.read(2), b'\r\n') - self.assertEqual(child.read(), b'abc\r\n') + remaining = child.read() + if remaining.endswith(_CAT_EOF): + remaining = remaining[:-len(_CAT_EOF)] + self.assertEqual(remaining, b'abc\r\n') def test_readline (self): '''See the note in test_readlines() for an explaination as to why @@ -76,6 +82,8 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase): page = b"" for line in child: page = page + line + if page.endswith(_CAT_EOF): + page = page[:-len(_CAT_EOF)] assert (page == b'abc\r\nabc\r\n123\r\n123\r\n' or page == b'abc\r\n123\r\nabc\r\n123\r\n') , \ "iterator did not work. page=%s"%repr(page) @@ -100,6 +108,8 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase): child.sendeof() page = child.readlines() page = b''.join(page) + if page.endswith(_CAT_EOF): + page = page[:-len(_CAT_EOF)] assert (page == b'abc\r\nabc\r\n123\r\n123\r\n' or page == b'abc\r\n123\r\nabc\r\n123\r\n'), \ "readlines() did not work. page=%s"%repr(page) |
