Open bandophahita opened 4 months ago
The problem is isinstance(ScheduleStatus.POSTED, str)
returns true even though type(ScheduleStatus.POSTED)
returns <enum 'ScheduleStatus'>
.
I'm curious if we can get away with something like this:
def represent_prop(item: str | T | mock.Mock) -> str | mock.Mock:
"""Represent items in a manner suitable for the audience (logging)."""
if isinstance(item, mock.Mock):
return item
if hasmethod(item, "describe_to"):
return f"{item}"
if isisntance(item, Enum):
return repr(f"{item}")
if isinstance(item, str):
return repr(item)
...
Consider the following code
Which works fine but logs as follows:
What we really want is:
To avoid this we can wrap the enum in a string, but could perhaps
represent_prop
do this for us?