aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py3/patches
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/python/pytest/py3/patches
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/python/pytest/py3/patches')
-rw-r--r--contrib/python/pytest/py3/patches/03-limit-id.patch36
-rw-r--r--contrib/python/pytest/py3/patches/04-support-cyrillic-id.patch11
-rw-r--r--contrib/python/pytest/py3/patches/05-support-readline.patch69
-rw-r--r--contrib/python/pytest/py3/patches/06-support-ya-markers.patch14
-rw-r--r--contrib/python/pytest/py3/patches/07-disable-translate-non-printable.patch11
-rw-r--r--contrib/python/pytest/py3/patches/08-fix-win-peerdir.patch15
6 files changed, 156 insertions, 0 deletions
diff --git a/contrib/python/pytest/py3/patches/03-limit-id.patch b/contrib/python/pytest/py3/patches/03-limit-id.patch
new file mode 100644
index 0000000000..ba1c199517
--- /dev/null
+++ b/contrib/python/pytest/py3/patches/03-limit-id.patch
@@ -0,0 +1,36 @@
+--- contrib/python/pytest/py3/_pytest/python.py (index)
++++ contrib/python/pytest/py3/_pytest/python.py (working tree)
+@@ -1192,6 +1192,33 @@ def _idval(val, argname, idx, idfn, item, config):
+ return str(argname) + str(idx)
+
+
++def limit_idval(limit):
++ import functools
++
++ names = {}
++ limit -= 6
++ assert limit > 0
++
++ def decorator(func):
++ @functools.wraps(func)
++ def wrapper(*args, **kw):
++ idval = func(*args, **kw)
++ if len(idval) > limit:
++ prefix = idval[:limit]
++ # There might be same prefix for the different test cases - take item into account
++ name = "{}-{}".format(kw.get('item', ''), prefix)
++ idx = names.setdefault(name, -1) + 1
++ names[name] = idx
++ idval = "{}-{}".format(prefix, idx)
++ return idval
++
++ return wrapper
++
++ return decorator
++
++
++# XXX limit testnames in the name of sanity and readability
++@limit_idval(limit=500)
+ def _idvalset(
+ idx: int,
+ parameterset: ParameterSet,
diff --git a/contrib/python/pytest/py3/patches/04-support-cyrillic-id.patch b/contrib/python/pytest/py3/patches/04-support-cyrillic-id.patch
new file mode 100644
index 0000000000..c45fd08282
--- /dev/null
+++ b/contrib/python/pytest/py3/patches/04-support-cyrillic-id.patch
@@ -0,0 +1,11 @@
+--- contrib/python/pytest/py3/_pytest/compat.py (index)
++++ contrib/python/pytest/py3/_pytest/compat.py (working tree)
+@@ -255,7 +255,7 @@ if _PY3:
+ if isinstance(val, bytes):
+ ret = _bytes_to_ascii(val)
+ else:
+- ret = val.encode("unicode_escape").decode("ascii")
++ ret = val
+ return _translate_non_printable(ret)
+
+
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..11d6b94f0d
--- /dev/null
+++ b/contrib/python/pytest/py3/patches/05-support-readline.patch
@@ -0,0 +1,69 @@
+--- contrib/python/pytest/py3/_pytest/debugging.py (index)
++++ contrib/python/pytest/py3/_pytest/debugging.py (working tree)
+@@ -1,6 +1,7 @@ from __future__ import absolute_import
+ """ interactive debugging with PDB, the Python Debugger. """
+ import argparse
+ import functools
++import os
+ import sys
+
+ from _pytest import outcomes
+@@ -9,6 +10,42 @@ from _pytest import outcomes
+ from _pytest.config.exceptions import UsageError
+
+
++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):
+ """Validate syntax of --pdbcls option."""
+ try:
+@@ -250,6 +287,7 @@ class pytestPDB(object):
+ @classmethod
+ def set_trace(cls, *args, **kwargs) -> None:
+ """Invoke debugging via ``Pdb.set_trace``, dropping any IO capturing."""
++ tty()
+ frame = sys._getframe().f_back
+ _pdb = cls._init_pdb("set_trace", *args, **kwargs)
+ _pdb.set_trace(frame)
+@@ -292,6 +330,7 @@ class PdbInvoke(object):
+ out, err = capman.read_global_capture()
+ sys.stdout.write(out)
+ sys.stdout.write(err)
++ tty()
+ _enter_pdb(node, call.excinfo, report)
+
+ def pytest_internalerror(self, excrepr, excinfo):
diff --git a/contrib/python/pytest/py3/patches/06-support-ya-markers.patch b/contrib/python/pytest/py3/patches/06-support-ya-markers.patch
new file mode 100644
index 0000000000..373d89c866
--- /dev/null
+++ b/contrib/python/pytest/py3/patches/06-support-ya-markers.patch
@@ -0,0 +1,14 @@
+--- contrib/python/pytest/py3/_pytest/mark/structures.py (index)
++++ contrib/python/pytest/py3/_pytest/mark/structures.py (working tree)
+@@ -326,7 +326,10 @@ class MarkGenerator(object):
+ # example lines: "skipif(condition): skip the given test if..."
+ # or "hypothesis: tests which use Hypothesis", so to get the
+ # marker name we split on both `:` and `(`.
+- marker = line.split(":")[0].split("(")[0].strip()
++ if line == "ya:external":
++ marker = line
++ else:
++ marker = line.split(":")[0].split("(")[0].strip()
+ self._markers.add(marker)
+
+ # If the name is not in the set of known marks after updating,
diff --git a/contrib/python/pytest/py3/patches/07-disable-translate-non-printable.patch b/contrib/python/pytest/py3/patches/07-disable-translate-non-printable.patch
new file mode 100644
index 0000000000..1d0b80c6d4
--- /dev/null
+++ b/contrib/python/pytest/py3/patches/07-disable-translate-non-printable.patch
@@ -0,0 +1,11 @@
+--- contrib/python/pytest/py3/_pytest/compat.py (index)
++++ contrib/python/pytest/py3/_pytest/compat.py (working tree)
+@@ -256,7 +256,7 @@ if _PY3:
+ ret = _bytes_to_ascii(val)
+ else:
+ ret = val
+- return _translate_non_printable(ret)
++ return ret
+
+
+ @attr.s
diff --git a/contrib/python/pytest/py3/patches/08-fix-win-peerdir.patch b/contrib/python/pytest/py3/patches/08-fix-win-peerdir.patch
new file mode 100644
index 0000000000..d6a56ef6e0
--- /dev/null
+++ b/contrib/python/pytest/py3/patches/08-fix-win-peerdir.patch
@@ -0,0 +1,15 @@
+--- contrib/python/pytest/py3/ya.make (index)
++++ contrib/python/pytest/py3/ya.make (working tree)
+@@ -15,6 +15,12 @@ PEERDIR(
+ contrib/python/wcwidth
+ )
+
++IF (OS_WINDOWS)
++ PEERDIR(
++ contrib/python/atomicwrites
++ )
++ENDIF()
++
+ NO_LINT()
+
+ NO_CHECK_IMPORTS(