Ensure printable manually-specified param(id=...)
This commit is contained in:
parent
8395b9e25d
commit
9ca0ab6e2b
|
@ -8,6 +8,7 @@ import attr
|
||||||
import six
|
import six
|
||||||
from six.moves import map
|
from six.moves import map
|
||||||
|
|
||||||
|
from ..compat import ascii_escaped
|
||||||
from ..compat import getfslineno
|
from ..compat import getfslineno
|
||||||
from ..compat import MappingMixin
|
from ..compat import MappingMixin
|
||||||
from ..compat import NOTSET
|
from ..compat import NOTSET
|
||||||
|
@ -77,6 +78,7 @@ class ParameterSet(namedtuple("ParameterSet", "values, marks, id")):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
"Expected id to be a string, got {}: {!r}".format(type(id_), id_)
|
"Expected id to be a string, got {}: {!r}".format(type(id_), id_)
|
||||||
)
|
)
|
||||||
|
id_ = ascii_escaped(id_)
|
||||||
return cls(values, marks, id_)
|
return cls(values, marks, id_)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -394,6 +394,18 @@ class TestMetafunc(object):
|
||||||
)
|
)
|
||||||
assert result == ["\\x00-1", "\\x05-2", "\\x00-3", "\\x05-4"]
|
assert result == ["\\x00-1", "\\x05-2", "\\x00-3", "\\x05-4"]
|
||||||
|
|
||||||
|
def test_idmaker_manual_ids_must_be_printable(self):
|
||||||
|
from _pytest.python import idmaker
|
||||||
|
|
||||||
|
result = idmaker(
|
||||||
|
("s",),
|
||||||
|
[
|
||||||
|
pytest.param("x00", id="hello \x00"),
|
||||||
|
pytest.param("x05", id="hello \x05"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
assert result == ["hello \\x00", "hello \\x05"]
|
||||||
|
|
||||||
def test_idmaker_enum(self):
|
def test_idmaker_enum(self):
|
||||||
from _pytest.python import idmaker
|
from _pytest.python import idmaker
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue