diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 87d4d51c1..1857f51a8 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -185,6 +185,9 @@ def get_default_arg_names(function): _non_printable_ascii_translate_table = { i: u"\\x{:02x}".format(i) for i in range(128) if i not in range(32, 127) } +_non_printable_ascii_translate_table.update( + {ord("\t"): u"\\t", ord("\r"): u"\\r", ord("\n"): u"\\n"} +) def _translate_non_printable(s): diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index ef6993d94..0d5b6037f 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -390,9 +390,11 @@ class TestMetafunc(object): pytest.param("\x05", 2), pytest.param(b"\x00", 3), pytest.param(b"\x05", 4), + pytest.param("\t", 5), + pytest.param(b"\t", 6), ], ) - assert result == ["\\x00-1", "\\x05-2", "\\x00-3", "\\x05-4"] + assert result == ["\\x00-1", "\\x05-2", "\\x00-3", "\\x05-4", "\\t-5", "\\t-6"] def test_idmaker_manual_ids_must_be_printable(self): from _pytest.python import idmaker