Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Actors are the stars of the show. They perform your actions, ask questions
- about the state of the application, and assert resolutions, all in the
- service of perfoming their roles. You can give a curtain call for a new
- actor like so:
- Perry = AnActor.named("Perry") TODO CHange me
- """
- from loguru import logger
- from screenpy.actor import Actor as OriginalActor
- from random import choice
- from typing import Any, List, Text, Tuple
- from hamcrest import assert_that
- from screenpy.exceptions import UnableToPerform
- from screenpy.pacing import aside
- # For type-hinting
- Ability = Any
- Action = Any
- Question = Any
- Resolution = Any
- class ModifiedActor(OriginalActor):
- """
- I AM A MODIFIED ACTOR
- Represents an actor, holding their name and abilities. Actors are the
- performers of your screenplay, they represent your users as they go
- about their business on your product.
- An actor is meant to be instantiated using its static |Actor.named|
- method. A typical invocation might look like:
- Perry = Actor.named("Perry")
- This will create the actor, ready to take on their first role.
- """
- def should_see_either_or(self, *tests: Tuple[Question, Resolution]) -> None:
- """
- Ask a series of questions, asserting their expected answers.
- Args:
- tests: tuples of a |Question| and a |Resolution|.
- Raises:
- AssertionError: If the question's actual answer does not match
- the expected answer from the |Resolution|.
- """
- tests_count = len(tests)
- success_count = 0
- failure_count = 0
- for question, test in tests:
- try:
- assert_that(question.answered_by(self), test)
- success_count += 1
- logger.trace(f"Test succeeded, and it's succession #{success_count} out of {tests_count}")
- except AssertionError as e:
- failure_count += 1
- logger.warning(f"{e}, and it's failure #{failure_count} out of {tests_count}")
- if success_count < 1:
- logger.error(f"Every test out of {tests} has failed")
- raise AssertionError("Every test has failed")
- should_see_that_either_or = should_see_either_or
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement