ScreenPyHQ / screenpy

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

create properites for `item_to_log` #108

Open bandophahita opened 11 months ago

bandophahita commented 11 months ago

Assuming we don't completely overhaul the way beat messages are handled; there are several classes that transform the argument for proper logging. The arguments are transformed in the constructor which in most cases is sufficient but should the tester ever want to manipulate the attribute after the object has been instantiated the logging will not match.

example:

class MakeNote:
    def describe(self: SelfMakeNote) -> str:
        return f"Make a note under {represent_prop(self.key)}."

    @beat("{} jots something down under {key_to_log}.")
    def perform_as(self: SelfMakeNote, the_actor: Actor) -> None:
        ...

    def __init__(
        self: SelfMakeNote,
        question: T_Q,
        key: Optional[str] = None,
    ) -> None:
        self.question = question
        self.key = key
        self.key_to_log = represent_prop(key)

These attributes should be turned into a more dynamic property.