Author: Stefano Rivera <[email protected]>
Branch:
Changeset: r83515:accad9a1fe9c
Date: 2016-04-04 16:45 -0700
http://bitbucket.org/pypy/pypy/changeset/accad9a1fe9c/
Log: Pretend to be using a terminal that supports clear
Some tests use readline on an internal pty. These fail if TERM is
not set to a terminal that supports "clear".
diff --git a/pypy/module/test_lib_pypy/pyrepl/infrastructure.py
b/pypy/module/test_lib_pypy/pyrepl/infrastructure.py
--- a/pypy/module/test_lib_pypy/pyrepl/infrastructure.py
+++ b/pypy/module/test_lib_pypy/pyrepl/infrastructure.py
@@ -18,6 +18,9 @@
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
from __future__ import print_function
+from contextlib import contextmanager
+import os
+
from pyrepl.reader import Reader
from pyrepl.console import Console, Event
@@ -71,3 +74,14 @@
con = TestConsole(test_spec, verbose=True)
reader = reader_class(con)
reader.readline()
+
+
+@contextmanager
+def sane_term():
+ """Ensure a TERM that supports clear"""
+ old_term, os.environ['TERM'] = os.environ.get('TERM'), 'xterm'
+ yield
+ if old_term is not None:
+ os.environ['TERM'] = old_term
+ else:
+ del os.environ['TERM']
diff --git a/pypy/module/test_lib_pypy/pyrepl/test_bugs.py
b/pypy/module/test_lib_pypy/pyrepl/test_bugs.py
--- a/pypy/module/test_lib_pypy/pyrepl/test_bugs.py
+++ b/pypy/module/test_lib_pypy/pyrepl/test_bugs.py
@@ -18,7 +18,7 @@
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
from pyrepl.historical_reader import HistoricalReader
-from .infrastructure import EA, BaseTestReader, read_spec
+from .infrastructure import EA, BaseTestReader, sane_term, read_spec
# this test case should contain as-verbatim-as-possible versions of
# (applicable) bug reports
@@ -62,13 +62,14 @@
mfd, sfd = pty.openpty()
try:
- c = UnixConsole(sfd, sfd)
- c.prepare()
- c.restore()
- monkeypatch.setattr(signal, 'signal', failing_signal)
- c.prepare()
- monkeypatch.setattr(signal, 'signal', really_failing_signal)
- c.restore()
+ with sane_term():
+ c = UnixConsole(sfd, sfd)
+ c.prepare()
+ c.restore()
+ monkeypatch.setattr(signal, 'signal', failing_signal)
+ c.prepare()
+ monkeypatch.setattr(signal, 'signal', really_failing_signal)
+ c.restore()
finally:
os.close(mfd)
os.close(sfd)
diff --git a/pypy/module/test_lib_pypy/pyrepl/test_readline.py
b/pypy/module/test_lib_pypy/pyrepl/test_readline.py
--- a/pypy/module/test_lib_pypy/pyrepl/test_readline.py
+++ b/pypy/module/test_lib_pypy/pyrepl/test_readline.py
@@ -1,5 +1,7 @@
import pytest
+from .infrastructure import sane_term
+
@pytest.mark.skipif("os.name != 'posix' or 'darwin' in sys.platform or "
"'kfreebsd' in sys.platform")
@@ -12,7 +14,8 @@
readline_wrapper = _ReadlineWrapper(slave, slave)
os.write(master, b'input\n')
- result = readline_wrapper.get_reader().readline()
+ with sane_term():
+ result = readline_wrapper.get_reader().readline()
#result = readline_wrapper.raw_input('prompt:')
assert result == 'input'
# A bytes string on python2, a unicode string on python3.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit