aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py2/patches/04-fix-id-encoding.patch
diff options
context:
space:
mode:
authormaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 12:29:46 +0300
committermaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 13:14:22 +0300
commit9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch)
treea8fb3181d5947c0d78cf402aa56e686130179049 /contrib/python/pytest/py2/patches/04-fix-id-encoding.patch
parenta44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff)
downloadydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz
publishFullContrib: true for ydb
<HIDDEN_URL> commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/python/pytest/py2/patches/04-fix-id-encoding.patch')
-rw-r--r--contrib/python/pytest/py2/patches/04-fix-id-encoding.patch57
1 files changed, 57 insertions, 0 deletions
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 0000000000..e70af52d19
--- /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
+ )
+
+