Skip to content

Commit

Permalink
fixing python code blocks to be consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
bandophahita committed Aug 21, 2023
1 parent c0ee186 commit c5b54f9
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Retrieving Initial Answers
Some tests may need to ensure something has changed.
You are able to retrieve
the answers to Questions
anywhere you may need to::
anywhere you may need to.

.. code-block:: python
empty_todo_list_text = Text.of_the(TODO_LIST).answered_by(Wanda)
Expand All @@ -27,7 +29,9 @@ Using MakeNote
You can also retrieve initial answers
with the :class:`~screenpy.actions.MakeNote` class,
and retrieve the value
with a :ref:`direction <directions>`::
with a :ref:`direction <directions>`
.. code-block:: python
when(Cameron).attempts_to(
StartRecording(),
Expand All @@ -48,7 +52,9 @@ There is one limitation
to using :class:`~screenpy.actions.MakeNote`:
it is not possible
to make a note and retrieve it
in the same Actions list::
in the same Actions list.

.. code-block:: python
# CAN NOT do this:
when(Perry).attempts_to(
Expand Down Expand Up @@ -95,7 +101,9 @@ and performs it,
repeatedly,
until either it succeeds
or the timeout expires.
Here's what that looks like::
Here's what that looks like.

.. code-block:: python
Marcel.attempts_to(
Eventually(
Expand Down Expand Up @@ -166,7 +174,9 @@ your Actors may need one or more of their Abilities
to do some cleanup.
You can assign cleanup tasks to your Actor
using their :meth:`~screenpy.actor.Actor.has_ordered_cleanup_tasks`
or :meth:`~screenpy.actor.Actor.has_independent_cleanup_tasks` method::
or :meth:`~screenpy.actor.Actor.has_independent_cleanup_tasks` method:

.. code-block:: python
Perry = AnActor.named("Perry").who_can(BrowseTheWeb.using_firefox())
Perry.has_ordered_cleanup_tasks(CompleteAllTodoItems())
Expand Down Expand Up @@ -198,7 +208,9 @@ Sometimes you only need logging when things go wrong.
to only log the important things when things go right.
Everything inside of ``Silently`` is prevented from logging.

Example: The following Action::
Example: The following Action

.. code-block:: python
class PerformChatty(Performable):
@beat("{} tries to PerformChatty")
Expand All @@ -221,8 +233,11 @@ Would generate this log::
... hoping it's equal to True.
=> <True>

But what if perhaps, we didn't need to know all the steps being taken at in ``PerformChatty`` unless they were to fail?
Wrapping ``PerformA`` in ``Silently``::
But what if perhaps, we didn't need to know all the steps being taken at in
``PerformChatty`` unless they were to fail?
Wrapping ``PerformA`` in ``Silently``

.. code-block:: python
class PerformChatty(Performable):
@beat("{} tries to PerformChatty")
Expand Down Expand Up @@ -256,7 +271,9 @@ Using Either

Sometimes you may need to use a try/except control flow in your test, for
one reason or another. Luckily, your Actor can perform this flow
with the :class:`~screenpy.actions.Either` Action!::
with the :class:`~screenpy.actions.Either` Action!

.. code-block:: python
the_actor.will(Either(DoAction()).or_(DoDifferentAction())
Expand All @@ -266,7 +283,9 @@ begin performing the second action (or set of actions) passed into :meth:`~scree
Note the Actor only catches ``AssertionError`` here allowing for other exceptions to still be raised.
:class:`~screenpy.actions.Either` allows users to pass in multiple actions. This is
similar Actor performing multiple actions in one call::
similar Actor performing multiple actions in one call.
.. code-block:: python
the_actor.will(
Either(
Expand All @@ -286,7 +305,10 @@ similar Actor performing multiple actions in one call::
after it experiences a failure in the first routine; the Actor will proceed directly
to the second routine. Keep this in mind while defining the two branches of Actions.
To help illustrate this further here is a real-world example using `screenpy_selenium <https://screenpy-selenium-docs.readthedocs.io/en/latest/>`__::
To help illustrate this further here is a real-world example
using `screenpy_selenium <https://screenpy-selenium-docs.readthedocs.io/en/latest/>`__
.. code-block:: python
the_actor.will(
Either(
Expand Down

0 comments on commit c5b54f9

Please sign in to comment.