Skip to content

Commit

Permalink
run make pre-check-in-fix, woops.
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygoy committed Apr 30, 2024
1 parent 2d532b2 commit e0aaae3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
19 changes: 11 additions & 8 deletions screenpy/actions/stop.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
"""Tell an Actor to Stop!"""

from typing import TYPE_CHECKING
from __future__ import annotations

from typing_extensions import Self
from typing import TYPE_CHECKING

from screenpy.actor import Actor
from screenpy.configuration import settings
from screenpy.exceptions import DeliveryError
from screenpy.pacing import beat
from screenpy.protocols import Answerable, Resolvable
from screenpy.configuration import settings
from screenpy.speech_tools import get_additive_description

from .eventually import Eventually
from .see import See
from .silently import Silently

if TYPE_CHECKING:
from typing_extensions import Self

from screenpy import Actor
from screenpy.protocols import Answerable, Resolvable


class Stop:
Expand Down Expand Up @@ -48,7 +49,9 @@ def until_the(cls, question: Answerable, resolution: Resolvable) -> Self:
"""Specify the condition to wait for."""
return cls(question, resolution)

def __init__(self, question: Answerable | None = None, resolution: Resolvable | None = None) -> None:
def __init__(
self, question: Answerable | None = None, resolution: Resolvable | None = None
) -> None:
self.question = question
self.resolution = resolution

Expand All @@ -71,12 +74,12 @@ def description_to_log(self) -> str:
"""Represent the Action in a log-friendly way."""
if self.question is None and self.resolution is None:
return "they hear your cue"
return f"{self.question_to_log} is {self.resolution_to_log}";
return f"{self.question_to_log} is {self.resolution_to_log}"

@beat("{} stops until {description_to_log}.")
def perform_as(self, the_actor: Actor) -> None:
"""Direct the Actor to stop until the condition is met."""
if self.question is None and self.resolution is None:
if self.question is None or self.resolution is None:
msg = (
"\n\nThe Actor stops suddenly, waiting for your cue..."
"\n (press enter to continue): "
Expand Down
7 changes: 6 additions & 1 deletion tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ def perform_as(self, the_actor: Actor) -> None:
# kink, which will then be cleared by the outer Silently.
assert [r.msg for r in caplog.records] == []


class TestStop:
def test_can_be_instantiated(self) -> None:
s1 = Stop()
Expand All @@ -1085,8 +1086,12 @@ def test_describe(self) -> None:
s1 = Stop()
s2 = Stop.until_the(mock_question, mock_resolution)

expected_description = (
"Stop until the number of stars in the sky"
" is equal to the stars in your eyes."
)
assert s1.describe() == "Stop until they hear your cue."
assert s2.describe() == "Stop until the number of stars in the sky is equal to the stars in your eyes."
assert s2.describe() == expected_description

def test_calls_input_with_no_question_and_resolution(self, Tester: Actor) -> None:
with mock.patch("builtins.input", return_value="") as mocked_input:
Expand Down

0 comments on commit e0aaae3

Please sign in to comment.