Skip to content

Commit

Permalink
parametrize: allow __name__ id for modules or other objects as well
Browse files Browse the repository at this point in the history
  • Loading branch information
grlee77 committed Nov 8, 2019
1 parent 6ad9571 commit c22ce1a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c22ce1a

Please sign in to comment.