diff options
| author | maxim-yurchuk <[email protected]> | 2024-10-09 12:29:46 +0300 |
|---|---|---|
| committer | maxim-yurchuk <[email protected]> | 2024-10-09 13:14:22 +0300 |
| commit | 9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch) | |
| tree | a8fb3181d5947c0d78cf402aa56e686130179049 /contrib/python/pytest | |
| parent | a44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff) | |
publishFullContrib: true for ydb
<HIDDEN_URL>
commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/python/pytest')
15 files changed, 382 insertions, 0 deletions
diff --git a/contrib/python/pytest/py2/patches/01-disable-warnings.patch b/contrib/python/pytest/py2/patches/01-disable-warnings.patch new file mode 100644 index 00000000000..b556f43bc73 --- /dev/null +++ b/contrib/python/pytest/py2/patches/01-disable-warnings.patch @@ -0,0 +1,12 @@ +--- contrib/python/pytest/py2/_pytest/assertion/rewrite.py (index) ++++ contrib/python/pytest/py2/_pytest/assertion/rewrite.py (working tree) +@@ -4,6 +4,9 @@ from __future__ import absolute_import + from __future__ import division + from __future__ import print_function + ++import warnings ++warnings.filterwarnings("ignore", category=DeprecationWarning, module="_pytest.assertion.rewrite") ++ + import ast + import errno + import imp diff --git a/contrib/python/pytest/py2/patches/03-limit-id.patch b/contrib/python/pytest/py2/patches/03-limit-id.patch new file mode 100644 index 00000000000..5389c9290e5 --- /dev/null +++ b/contrib/python/pytest/py2/patches/03-limit-id.patch @@ -0,0 +1,36 @@ +--- contrib/python/pytest/py2/_pytest/python.py (index) ++++ contrib/python/pytest/py2/_pytest/python.py (working tree) +@@ -1204,6 +1204,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, parameterset, argnames, idfn, ids, item, config): + if parameterset.id is not None: + return parameterset.id diff --git a/contrib/python/pytest/py2/patches/04-fix-id-encoding.patch b/contrib/python/pytest/py2/patches/04-fix-id-encoding.patch new file mode 100644 index 00000000000..e70af52d191 --- /dev/null +++ b/contrib/python/pytest/py2/patches/04-fix-id-encoding.patch @@ -0,0 +1,57 @@ +--- contrib/python/pytest/py2/_pytest/compat.py (index) ++++ contrib/python/pytest/py2/_pytest/compat.py (working tree) +@@ -378,7 +378,10 @@ if _PY3: + + def safe_str(v): + """returns v as string""" +- return str(v) ++ try: ++ return str(v) ++ except UnicodeEncodeError: ++ return str(v, encoding="utf-8") + + + else: +--- contrib/python/pytest/py2/_pytest/python.py (index) ++++ contrib/python/pytest/py2/_pytest/python.py (working tree) +@@ -896,7 +896,7 @@ class CallSpec2(object): + + @property + def id(self): +- return "-".join(map(str, filter(None, self._idlist))) ++ return "-".join(map(safe_str, filter(None, self._idlist))) + + def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum, param_index): + for arg, val in zip(argnames, valset): +@@ -1218,10 +1218,10 @@ def limit_idval(limit): + 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) ++ name = "{}-{}".format(kw.get('item', ''), safe_str(prefix)) + idx = names.setdefault(name, -1) + 1 + names[name] = idx +- idval = "{}-{}".format(prefix, idx) ++ idval = "{}-{}".format(safe_str(prefix), idx) + return idval + + return wrapper +--- contrib/python/pytest/py2/_pytest/runner.py (index) ++++ contrib/python/pytest/py2/_pytest/runner.py (working tree) +@@ -16,6 +16,7 @@ from .reports import CollectErrorRepr + from .reports import CollectReport + from .reports import TestReport + from _pytest._code.code import ExceptionInfo ++from _pytest.compat import safe_str + from _pytest.outcomes import Exit + from _pytest.outcomes import Skipped + from _pytest.outcomes import TEST_OUTCOME +@@ -241,7 +242,7 @@ class CallInfo(object): + value = repr(self._result) + status = "result" + return "<CallInfo when={when!r} {status}: {value}>".format( +- when=self.when, value=value, status=status ++ when=self.when, value=safe_str(value), status=status + ) + + diff --git a/contrib/python/pytest/py2/patches/04-support-cyrillic-id.patch b/contrib/python/pytest/py2/patches/04-support-cyrillic-id.patch new file mode 100644 index 00000000000..26242ff9704 --- /dev/null +++ b/contrib/python/pytest/py2/patches/04-support-cyrillic-id.patch @@ -0,0 +1,26 @@ +--- contrib/python/pytest/py2/_pytest/compat.py (index) ++++ contrib/python/pytest/py2/_pytest/compat.py (working tree) +@@ -243,7 +243,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) + + +@@ -262,11 +262,11 @@ else: + """ + if isinstance(val, bytes): + try: +- ret = val.decode("ascii") ++ ret = val.decode("utf-8") + except UnicodeDecodeError: +- ret = val.encode("string-escape").decode("ascii") ++ ret = val.decode("utf-8", "ignore") + else: +- ret = val.encode("unicode-escape").decode("ascii") ++ ret = val.encode("utf-8", "replace").decode("utf-8") + return _translate_non_printable(ret) + + diff --git a/contrib/python/pytest/py2/patches/05-support-readline.patch b/contrib/python/pytest/py2/patches/05-support-readline.patch new file mode 100644 index 00000000000..51c6ee2bf46 --- /dev/null +++ b/contrib/python/pytest/py2/patches/05-support-readline.patch @@ -0,0 +1,69 @@ +--- contrib/python/pytest/py2/_pytest/debugging.py (index) ++++ contrib/python/pytest/py2/_pytest/debugging.py (working tree) +@@ -4,6 +4,7 @@ from __future__ import absolute_import + from __future__ import division + from __future__ import print_function + ++import os + import argparse + import pdb + import sys +@@ -14,6 +15,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: +@@ -249,6 +286,7 @@ class pytestPDB(object): + @classmethod + def set_trace(cls, *args, **kwargs): + """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) +@@ -262,6 +300,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/py2/patches/06-support-ya-markers.patch b/contrib/python/pytest/py2/patches/06-support-ya-markers.patch new file mode 100644 index 00000000000..6dae352ef8b --- /dev/null +++ b/contrib/python/pytest/py2/patches/06-support-ya-markers.patch @@ -0,0 +1,14 @@ +--- contrib/python/pytest/py2/_pytest/mark/structures.py (index) ++++ contrib/python/pytest/py2/_pytest/mark/structures.py (working tree) +@@ -316,7 +316,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/py2/patches/07-disable-translate-non-printable.patch b/contrib/python/pytest/py2/patches/07-disable-translate-non-printable.patch new file mode 100644 index 00000000000..beed7a0aeb7 --- /dev/null +++ b/contrib/python/pytest/py2/patches/07-disable-translate-non-printable.patch @@ -0,0 +1,20 @@ +--- contrib/python/pytest/py2/_pytest/compat.py (index) ++++ contrib/python/pytest/py2/_pytest/compat.py (working tree) +@@ -244,7 +244,7 @@ if _PY3: + ret = _bytes_to_ascii(val) + else: + ret = val +- return _translate_non_printable(ret) ++ return ret + + + else: +@@ -267,7 +267,7 @@ else: + ret = val.decode("utf-8", "ignore") + else: + ret = val.encode("utf-8", "replace").decode("utf-8") +- return _translate_non_printable(ret) ++ return ret + + + class _PytestWrapper(object): diff --git a/contrib/python/pytest/py2/patches/08-backport-pr-6607.patch b/contrib/python/pytest/py2/patches/08-backport-pr-6607.patch new file mode 100644 index 00000000000..8d0ae7a5fbf --- /dev/null +++ b/contrib/python/pytest/py2/patches/08-backport-pr-6607.patch @@ -0,0 +1,17 @@ +commit 46b46cea857997531a7b9b4de32556be50bd5aea (HEAD -> pytest-backport-pr-6607) +author: danila-eremin +date: 2022-01-22T16:55:07+03:00 + + backport py2 + +--- contrib/python/pytest/py2/_pytest/python.py (b87553999455f0084413c5b59139aa9ccb5e3f52) ++++ contrib/python/pytest/py2/_pytest/python.py (46b46cea857997531a7b9b4de32556be50bd5aea) +@@ -896,7 +896,7 @@ class CallSpec2(object): + + @property + def id(self): +- return "-".join(map(safe_str, filter(None, self._idlist))) ++ return "-".join(map(safe_str, self._idlist)) + + def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum, param_index): + for arg, val in zip(argnames, valset): diff --git a/contrib/python/pytest/py3/.yandex_meta/yamaker.yaml b/contrib/python/pytest/py3/.yandex_meta/yamaker.yaml new file mode 100644 index 00000000000..8f67972c48b --- /dev/null +++ b/contrib/python/pytest/py3/.yandex_meta/yamaker.yaml @@ -0,0 +1,2 @@ +exclude: + - py.py 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 00000000000..85215493617 --- /dev/null +++ b/contrib/python/pytest/py3/patches/03-limit-id.patch @@ -0,0 +1,31 @@ +--- contrib/python/pytest/py3/_pytest/python.py (index) ++++ contrib/python/pytest/py3/_pytest/python.py (working tree) +@@ -991,7 +991,7 @@ class IdMaker: + The counter suffix is appended only in case a string wouldn't be unique + otherwise. + """ +- resolved_ids = list(self._resolve_ids()) ++ resolved_ids = list(self._limit_ids(self._resolve_ids(), limit=500)) + # All IDs must be unique! + if len(resolved_ids) != len(set(resolved_ids)): + # Record the number of occurrences of each ID. +@@ -1005,6 +1005,19 @@ class IdMaker: + id_suffixes[id] += 1 + return resolved_ids + ++ def _limit_ids(self, ids, limit=500): ++ prefix_count = {} ++ limit -= 6 ++ assert limit > 0 ++ ++ for idval in ids: ++ if len(idval) > limit: ++ prefix = idval[:limit] ++ idx = prefix_count.get(prefix, -1) + 1 ++ prefix_count[prefix] = idx ++ idval = "{}-{}".format(prefix, idx) ++ yield idval ++ + def _resolve_ids(self) -> Iterable[str]: + """Resolve IDs for all ParameterSets (may contain duplicates).""" + for idx, parameterset in enumerate(self.parametersets): 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 00000000000..e77009678e4 --- /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) +@@ -249,7 +249,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 00000000000..4e5ee9767db --- /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 + 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 00000000000..84350938189 --- /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) +@@ -524,7 +524,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 00000000000..ada62a5e605 --- /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) +@@ -250,7 +250,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-collision-with-py.patch b/contrib/python/pytest/py3/patches/08-fix-collision-with-py.patch new file mode 100644 index 00000000000..e82591c1d5c --- /dev/null +++ b/contrib/python/pytest/py3/patches/08-fix-collision-with-py.patch @@ -0,0 +1,8 @@ +--- contrib/python/pytest/py3/_pytest/compat.py (index) ++++ contrib/python/pytest/py3/_pytest/compat.py (working tree) +@@ -22,1 +22,1 @@ from typing import Union +-import py ++import _pytest._py.path as py_path +@@ -46,1 +46,1 @@ _S = TypeVar("_S") +-LEGACY_PATH = py.path. local ++LEGACY_PATH = py_path. local |
