ScreenPyHQ / screenpy

Screenplay pattern base for Python automated UI test suites.
MIT License
27 stars 3 forks source link

beat doesn't log when `None` was returned. #101

Closed bandophahita closed 11 months ago

bandophahita commented 11 months ago

I noticed that questions -- that uses a beat -- which could return None as a value do not get logged.

Here is what gets logged:

Actor examines thing
... hoping it's equal to <None>
    => <None>

Here is what I would expect to get logged:

Actor examines thing
    => <None>
... hoping it's equal to <None>
    => <None>
bandophahita commented 11 months ago

And in case it was not obvious (it wasn't to me) the reason the resolution got logged in this case was because of the way hamcrest deals with logged values. None is wrapped in the IsEqual object. When we do a is not None check it passes because the object isn't None. Those clever folks at hamcrest...

                if retval is not None:
                    aside(f"=> {represent_prop(retval)}")
perrygoy commented 11 months ago

i think we can probably do something like:

if retval is not None or isinstance(func, Answerable):
    ...

or maybe keep a log of which protocols will be expected to return useful information from their -able method.

bandophahita commented 11 months ago

Unfortunately func isn't an instance of the protocols, it's function. We might have to get creative on how we identify which functions are allowed to return None.