Properly escape \r \n \t bytes
This commit is contained in:
parent
9a1e518cc3
commit
95c6d591f7
|
@ -185,6 +185,9 @@ def get_default_arg_names(function):
|
||||||
_non_printable_ascii_translate_table = {
|
_non_printable_ascii_translate_table = {
|
||||||
i: u"\\x{:02x}".format(i) for i in range(128) if i not in range(32, 127)
|
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):
|
def _translate_non_printable(s):
|
||||||
|
|
|
@ -390,9 +390,11 @@ class TestMetafunc(object):
|
||||||
pytest.param("\x05", 2),
|
pytest.param("\x05", 2),
|
||||||
pytest.param(b"\x00", 3),
|
pytest.param(b"\x00", 3),
|
||||||
pytest.param(b"\x05", 4),
|
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):
|
def test_idmaker_manual_ids_must_be_printable(self):
|
||||||
from _pytest.python import idmaker
|
from _pytest.python import idmaker
|
||||||
|
|
Loading…
Reference in New Issue