parametrize: allow __name__ id for modules or other objects as well

This commit is contained in:
Gregory Lee 2019-11-08 00:52:43 -05:00
parent 6ad95716da
commit c22ce1a12c
1 changed files with 2 additions and 1 deletions

View File

@ -1162,7 +1162,8 @@ def _idval(val, argname, idx, idfn, item, config):
return ascii_escaped(val.pattern)
elif isinstance(val, enum.Enum):
return str(val)
elif (inspect.isclass(val) or inspect.isfunction(val)) and hasattr(val, "__name__"):
elif hasattr(val, "__name__") and isinstance(val.__name__, str):
# name of a class, function, module, etc.
return val.__name__
return str(argname) + str(idx)