Extend _pytest.python._idval to return __name__ of functions as well, not just for classes

This commit is contained in:
ST John
2017-11-29 16:17:49 +00:00
parent 88ed1ab648
commit 912330a7e2

View File

@@ -933,7 +933,7 @@ def _idval(val, argname, idx, idfn, config=None):
return ascii_escaped(val.pattern)
elif enum is not None and isinstance(val, enum.Enum):
return str(val)
elif isclass(val) and hasattr(val, '__name__'):
elif (isclass(val) or isfunction(val)) and hasattr(val, '__name__'):
return val.__name__
return str(argname) + str(idx)