Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/_pytest/setuponly.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

from _pytest._io.saferepr import saferepr


def pytest_addoption(parser):
group = parser.getgroup("debugconfig")
Expand Down Expand Up @@ -66,7 +68,7 @@ def _show_fixture_action(fixturedef, msg):
tw.write(" (fixtures used: {})".format(", ".join(deps)))

if hasattr(fixturedef, "cached_param"):
tw.write("[{}]".format(fixturedef.cached_param))
tw.write("[{}]".format(saferepr(fixturedef.cached_param, maxsize=80)))

tw.flush()

Expand Down
21 changes: 21 additions & 0 deletions testing/test_setup_show_bytes_param.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys


def test_setup_show_parametrized_fixture_bytes_no_byteswarning(testdir):
p = testdir.makepyfile(
"""
import pytest

@pytest.fixture(params=[b"Hello World"])
def data(request):
return request.param

def test_data(data):
pass
"""
)
# Run pytest via the Python interpreter to pass -bb so BytesWarning becomes an error.
result = testdir.run(sys.executable, "-bb", "-m", "pytest", "--setup-show", p)
assert result.ret == 0
# Verify that the bytes value is displayed using a repr-like format.
result.stdout.fnmatch_lines(["*SETUP F data?b'Hello World'?*"])