summaryrefslogtreecommitdiff
path: root/tests/test_log.py
diff options
context:
space:
mode:
authorjquast <contact@jeffquast.com>2013-09-22 09:17:39 -0400
committerjquast <contact@jeffquast.com>2013-09-22 09:17:39 -0400
commit09c2dd7900b34712cea1607bcda5d8f98e67923c (patch)
treec42fe0d49dc0fb6259fa338f93d09b3c9f3185da /tests/test_log.py
parente1eeefafd206b7d13b25f64bfb00f5d944690723 (diff)
downloadpexpect-git-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_log.py')
-rwxr-xr-xtests/test_log.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/test_log.py b/tests/test_log.py
index 3a926f6..debdccf 100755
--- a/tests/test_log.py
+++ b/tests/test_log.py
@@ -24,6 +24,9 @@ import os
import tempfile
import PexpectTestCase
+# the program cat(1) may display ^D\x08\x08 when \x04 (EOF, Ctrl-D) is sent
+_CAT_EOF = b'^D\x08\x08'
+
class TestCaseLog(PexpectTestCase.PexpectTestCase):
def test_log (self):
@@ -54,8 +57,9 @@ class TestCaseLog(PexpectTestCase.PexpectTestCase):
with open(filename, 'rb') as f:
lf = f.read()
os.unlink (filename)
- lf = lf.replace(b'\x04', b'')
- self.assertEqual(lf.rstrip(), b'This is a test.\r\nThis is a test.')
+ if lf.endswith(_CAT_EOF):
+ lf = lf[:-len(_CAT_EOF)]
+ self.assertEqual(lf, b'This is a test.\r\nThis is a test.\r\n')
def test_log_logfile_send (self):
log_message = b'This is a test.'
@@ -95,7 +99,10 @@ class TestCaseLog(PexpectTestCase.PexpectTestCase):
lf = f.read()
os.unlink(filename)
lf = lf.replace(b'\x04', b'')
- self.assertEqual(lf, b'This is a test.\nThis is a test.\r\nThis is a test.\r\n')
+ if lf.endswith(_CAT_EOF):
+ lf = lf[:-len(_CAT_EOF)]
+ self.assertEqual(lf,
+ b'This is a test.\nThis is a test.\r\nThis is a test.\r\n')
if __name__ == '__main__':
unittest.main()