04-fix-id-encoding.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --- contrib/python/pytest/py2/_pytest/compat.py (index)
  2. +++ contrib/python/pytest/py2/_pytest/compat.py (working tree)
  3. @@ -378,7 +378,10 @@ if _PY3:
  4. def safe_str(v):
  5. """returns v as string"""
  6. - return str(v)
  7. + try:
  8. + return str(v)
  9. + except UnicodeEncodeError:
  10. + return str(v, encoding="utf-8")
  11. else:
  12. --- contrib/python/pytest/py2/_pytest/python.py (index)
  13. +++ contrib/python/pytest/py2/_pytest/python.py (working tree)
  14. @@ -896,7 +896,7 @@ class CallSpec2(object):
  15. @property
  16. def id(self):
  17. - return "-".join(map(str, filter(None, self._idlist)))
  18. + return "-".join(map(safe_str, filter(None, self._idlist)))
  19. def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum, param_index):
  20. for arg, val in zip(argnames, valset):
  21. @@ -1218,10 +1218,10 @@ def limit_idval(limit):
  22. if len(idval) > limit:
  23. prefix = idval[:limit]
  24. # There might be same prefix for the different test cases - take item into account
  25. - name = "{}-{}".format(kw.get('item', ''), prefix)
  26. + name = "{}-{}".format(kw.get('item', ''), safe_str(prefix))
  27. idx = names.setdefault(name, -1) + 1
  28. names[name] = idx
  29. - idval = "{}-{}".format(prefix, idx)
  30. + idval = "{}-{}".format(safe_str(prefix), idx)
  31. return idval
  32. return wrapper
  33. --- contrib/python/pytest/py2/_pytest/runner.py (index)
  34. +++ contrib/python/pytest/py2/_pytest/runner.py (working tree)
  35. @@ -16,6 +16,7 @@ from .reports import CollectErrorRepr
  36. from .reports import CollectReport
  37. from .reports import TestReport
  38. from _pytest._code.code import ExceptionInfo
  39. +from _pytest.compat import safe_str
  40. from _pytest.outcomes import Exit
  41. from _pytest.outcomes import Skipped
  42. from _pytest.outcomes import TEST_OUTCOME
  43. @@ -241,7 +242,7 @@ class CallInfo(object):
  44. value = repr(self._result)
  45. status = "result"
  46. return "<CallInfo when={when!r} {status}: {value}>".format(
  47. - when=self.when, value=value, status=status
  48. + when=self.when, value=safe_str(value), status=status
  49. )