Fix #7126 - saferepr for bytes params

bytes parametrize parameters cause error when --setup-show is used
and Python is called with -bb flag
This commit is contained in:
Pavel Karateev
2020-05-09 13:57:17 +03:00
parent 741a8b8023
commit 903e2ab6ee
4 changed files with 28 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import pytest
from _pytest._io.saferepr import saferepr
def pytest_addoption(parser):
@@ -66,7 +67,11 @@ def _show_fixture_action(fixturedef, msg):
tw.write(" (fixtures used: {})".format(", ".join(deps)))
if hasattr(fixturedef, "cached_param"):
tw.write("[{}]".format(fixturedef.cached_param))
if isinstance(fixturedef.cached_param, bytes):
param = saferepr(fixturedef.cached_param, maxsize=42)
else:
param = fixturedef.cached_param
tw.write("[{}]".format(param))
tw.flush()