We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
represent_prop
Consider the following code
class ScheduleStatus(StrEnum): DRAFT = "DRAFT" POSTED = "POSTED" ARCHIVED = "ARCHIVED" actor.shall(See(Text(SCHEDULE_STATUS), ReadsExactly(ScheduleStatus.POSTED)))
Which works fine but logs as follows:
Marcel sees if the text from the schedule status is <ScheduleStatus.POSTED: 'POSTED'>, verbatim.
What we really want is:
Marcel sees if the text from the schedule status is 'POSTED', verbatim.
To avoid this we can wrap the enum in a string, but could perhaps represent_prop do this for us?
The text was updated successfully, but these errors were encountered:
The problem is isinstance(ScheduleStatus.POSTED, str) returns true even though type(ScheduleStatus.POSTED) returns <enum 'ScheduleStatus'>.
isinstance(ScheduleStatus.POSTED, str)
type(ScheduleStatus.POSTED)
<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) ...
Sorry, something went wrong.
No branches or pull requests
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?The text was updated successfully, but these errors were encountered: