replace all _escape_strings to _ascii_escaped
This commit is contained in:
parent
7cd03d7611
commit
80595115b0
|
@ -128,7 +128,7 @@ if _PY3:
|
||||||
STRING_TYPES = bytes, str
|
STRING_TYPES = bytes, str
|
||||||
UNICODE_TYPES = str,
|
UNICODE_TYPES = str,
|
||||||
|
|
||||||
def _escape_strings(val):
|
def _ascii_escaped(val):
|
||||||
"""If val is pure ascii, returns it as a str(). Otherwise, escapes
|
"""If val is pure ascii, returns it as a str(). Otherwise, escapes
|
||||||
bytes objects into a sequence of escaped bytes:
|
bytes objects into a sequence of escaped bytes:
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ else:
|
||||||
|
|
||||||
from itertools import imap # NOQA
|
from itertools import imap # NOQA
|
||||||
|
|
||||||
def _escape_strings(val):
|
def _ascii_escaped(val):
|
||||||
"""In py2 bytes and str are the same type, so return if it's a bytes
|
"""In py2 bytes and str are the same type, so return if it's a bytes
|
||||||
object, return it unchanged if it is a full ascii string,
|
object, return it unchanged if it is a full ascii string,
|
||||||
otherwise escape it into its binary form.
|
otherwise escape it into its binary form.
|
||||||
|
|
|
@ -18,7 +18,7 @@ import _pytest._pluggy as pluggy
|
||||||
from _pytest import fixtures
|
from _pytest import fixtures
|
||||||
from _pytest import main
|
from _pytest import main
|
||||||
from _pytest.compat import (
|
from _pytest.compat import (
|
||||||
isclass, isfunction, is_generator, _escape_strings,
|
isclass, isfunction, is_generator, _ascii_escaped,
|
||||||
REGEX_TYPE, STRING_TYPES, NoneType, NOTSET,
|
REGEX_TYPE, STRING_TYPES, NoneType, NOTSET,
|
||||||
get_real_func, getfslineno, safe_getattr,
|
get_real_func, getfslineno, safe_getattr,
|
||||||
safe_str, getlocation, enum,
|
safe_str, getlocation, enum,
|
||||||
|
@ -929,7 +929,7 @@ def _idval(val, argname, idx, idfn, config=None):
|
||||||
msg += '\nUpdate your code as this will raise an error in pytest-4.0.'
|
msg += '\nUpdate your code as this will raise an error in pytest-4.0.'
|
||||||
warnings.warn(msg, DeprecationWarning)
|
warnings.warn(msg, DeprecationWarning)
|
||||||
if s:
|
if s:
|
||||||
return _escape_strings(s)
|
return _ascii_escaped(s)
|
||||||
|
|
||||||
if config:
|
if config:
|
||||||
hook_id = config.hook.pytest_make_parametrize_id(
|
hook_id = config.hook.pytest_make_parametrize_id(
|
||||||
|
@ -938,11 +938,11 @@ def _idval(val, argname, idx, idfn, config=None):
|
||||||
return hook_id
|
return hook_id
|
||||||
|
|
||||||
if isinstance(val, STRING_TYPES):
|
if isinstance(val, STRING_TYPES):
|
||||||
return _escape_strings(val)
|
return _ascii_escaped(val)
|
||||||
elif isinstance(val, (float, int, bool, NoneType)):
|
elif isinstance(val, (float, int, bool, NoneType)):
|
||||||
return str(val)
|
return str(val)
|
||||||
elif isinstance(val, REGEX_TYPE):
|
elif isinstance(val, REGEX_TYPE):
|
||||||
return _escape_strings(val.pattern)
|
return _ascii_escaped(val.pattern)
|
||||||
elif enum is not None and isinstance(val, enum.Enum):
|
elif enum is not None and isinstance(val, enum.Enum):
|
||||||
return str(val)
|
return str(val)
|
||||||
elif isclass(val) and hasattr(val, '__name__'):
|
elif isclass(val) and hasattr(val, '__name__'):
|
||||||
|
@ -958,7 +958,7 @@ def _idvalset(idx, parameterset, argnames, idfn, ids, config=None):
|
||||||
for val, argname in zip(parameterset.values, argnames)]
|
for val, argname in zip(parameterset.values, argnames)]
|
||||||
return "-".join(this_id)
|
return "-".join(this_id)
|
||||||
else:
|
else:
|
||||||
return _escape_strings(ids[idx])
|
return _ascii_escaped(ids[idx])
|
||||||
|
|
||||||
|
|
||||||
def idmaker(argnames, parametersets, idfn=None, ids=None, config=None):
|
def idmaker(argnames, parametersets, idfn=None, ids=None, config=None):
|
||||||
|
|
Loading…
Reference in New Issue