diff options
-rwxr-xr-x | tests/deprecated_test_filedescriptor.py (renamed from tests/depricated_test_filedescriptor.py) | 0 | ||||
-rwxr-xr-x | tests/deprecated_test_run_out_of_pty.py (renamed from tests/test_run_out_of_pty.py) | 0 | ||||
-rwxr-xr-x | tests/test_ansi.py | 16 | ||||
-rwxr-xr-x | tests/test_expect.py | 2 | ||||
-rw-r--r-- | tests/test_which.py | 7 |
5 files changed, 21 insertions, 4 deletions
diff --git a/tests/depricated_test_filedescriptor.py b/tests/deprecated_test_filedescriptor.py index 6b0ef3e..6b0ef3e 100755 --- a/tests/depricated_test_filedescriptor.py +++ b/tests/deprecated_test_filedescriptor.py diff --git a/tests/test_run_out_of_pty.py b/tests/deprecated_test_run_out_of_pty.py index 3090147..3090147 100755 --- a/tests/test_run_out_of_pty.py +++ b/tests/deprecated_test_run_out_of_pty.py diff --git a/tests/test_ansi.py b/tests/test_ansi.py index a9d445e..3d73fe8 100755 --- a/tests/test_ansi.py +++ b/tests/test_ansi.py @@ -21,7 +21,10 @@ PEXPECT LICENSE from pexpect import ANSI import unittest from . import PexpectTestCase +import os +import shutil import sys +import tempfile PY3 = (sys.version_info[0] >= 3) @@ -120,8 +123,17 @@ class ansiTestCase (PexpectTestCase.PexpectTestCase): s = ANSI.ANSI (24,80) with open('torturet.vt') as f: sample_text = f.read() - for c in sample_text: - s.process (c) + # This causes ANSI.py's DoLog to write in the cwd. Make sure we're in a + # writeable directory. + d = tempfile.mkdtemp() + old_cwd = os.getcwd() + os.chdir(d) + try: + for c in sample_text: + s.process (c) + finally: + os.chdir(old_cwd) + shutil.rmtree(d) assert s.pretty() == torture_target, 'processed: \n' + s.pretty() + '\nexpected:\n' + torture_target def test_tetris (self): diff --git a/tests/test_expect.py b/tests/test_expect.py index 2c74744..c62231a 100755 --- a/tests/test_expect.py +++ b/tests/test_expect.py @@ -38,7 +38,7 @@ from .utils import no_coverage_env FILTER=''.join([(len(repr(chr(x)))==3) and chr(x) or '.' for x in range(256)]) def hex_dump(src, length=16): result=[] - for i in xrange(0, len(src), length): + for i in range(0, len(src), length): s = src[i:i+length] hexa = ' '.join(["%02X"%ord(x) for x in s]) printable = s.translate(FILTER) diff --git a/tests/test_which.py b/tests/test_which.py index 15a8944..e1b19a8 100644 --- a/tests/test_which.py +++ b/tests/test_which.py @@ -2,6 +2,7 @@ import subprocess import tempfile import shutil +import sys import errno import os @@ -41,8 +42,12 @@ class TestCaseWhich(PexpectTestCase.PexpectTestCase): " which() finds an executable in $PATH and returns its abspath. " bin_dir = tempfile.mkdtemp() + if sys.getfilesystemencoding() in ('ascii', 'ANSI_X3.4-1968'): + prefix = 'ascii-' + else: + prefix = u'ǝpoɔıun-' temp_obj = tempfile.NamedTemporaryFile( - suffix=u'.sh', prefix=u'ǝpoɔıun-', + suffix=u'.sh', prefix=prefix, dir=bin_dir, delete=False) bin_path = temp_obj.name fname = os.path.basename(temp_obj.name) |