diff options
author | maxim-yurchuk <maxim-yurchuk@yandex-team.com> | 2024-10-09 12:29:46 +0300 |
---|---|---|
committer | maxim-yurchuk <maxim-yurchuk@yandex-team.com> | 2024-10-09 13:14:22 +0300 |
commit | 9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch) | |
tree | a8fb3181d5947c0d78cf402aa56e686130179049 /contrib/python/pytest/py3/patches/05-support-readline.patch | |
parent | a44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff) | |
download | ydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz |
publishFullContrib: true for ydb
<HIDDEN_URL>
commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/python/pytest/py3/patches/05-support-readline.patch')
-rw-r--r-- | contrib/python/pytest/py3/patches/05-support-readline.patch | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/contrib/python/pytest/py3/patches/05-support-readline.patch b/contrib/python/pytest/py3/patches/05-support-readline.patch new file mode 100644 index 0000000000..4e5ee9767d --- /dev/null +++ b/contrib/python/pytest/py3/patches/05-support-readline.patch @@ -0,0 +1,54 @@ +--- contrib/python/pytest/py3/_pytest/debugging.py (index) ++++ contrib/python/pytest/py3/_pytest/debugging.py (working tree) +@@ -3,2 +3,3 @@ from __future__ import absolute_import + import functools ++import os + import sys +@@ -32,2 +33,38 @@ from _pytest import outcomes + ++def import_readline(): ++ try: ++ import readline ++ except ImportError: ++ sys.path.append('/usr/lib/python2.7/lib-dynload') ++ ++ try: ++ import readline ++ except ImportError as e: ++ print('can not import readline:', e) ++ ++ import subprocess ++ try: ++ subprocess.check_call('stty icrnl'.split()) ++ except OSError as e: ++ print('can not restore Enter, use Control+J:', e) ++ ++ ++def tty(): ++ if os.isatty(1): ++ return ++ ++ fd = os.open('/dev/tty', os.O_RDWR) ++ os.dup2(fd, 0) ++ os.dup2(fd, 1) ++ os.dup2(fd, 2) ++ os.close(fd) ++ ++ old_sys_path = sys.path ++ sys.path = list(sys.path) ++ try: ++ import_readline() ++ finally: ++ sys.path = old_sys_path ++ ++ + def _validate_usepdb_cls(value: str) -> Tuple[str, str]: +@@ -280,2 +317,3 @@ class pytestPDB(object): + """Invoke debugging via ``Pdb.set_trace``, dropping any IO capturing.""" ++ tty() + frame = sys._getframe().f_back +@@ -295,2 +333,3 @@ class PdbInvoke(object): + sys.stdout.write(err) ++ tty() + assert call.excinfo is not None + |