From 912330a7e2dfd67db252de4197b00a982043caf3 Mon Sep 17 00:00:00 2001 From: ST John Date: Wed, 29 Nov 2017 16:17:49 +0000 Subject: [PATCH] Extend _pytest.python._idval to return __name__ of functions as well, not just for classes --- _pytest/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pytest/python.py b/_pytest/python.py index 650171a9e..57ebcfbb3 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -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)