Skip to content

Commit

Permalink
#6: add additional examples for slicing.
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygoy committed Feb 12, 2024
1 parent 4bb1de6 commit 73dbe48
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions screenpy_requests/questions/body_of_the_last_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,35 @@ class BodyOfTheLastResponse:
If you are expecting a JSON response, this Question can be indexed to
return only a section of that response. See the examples below.
If you are expecting a text response, you can also slice the text.
Abilities Required:
:class:`~screenpy_requests.abilities.MakeAPIRequests`
Examples::
# JSON response
the_actor.should(
See.the(BodyOfTheLastResponse(), ContainsTheEntry(play="Hamlet"))
)
# JSON response, picked
the_actor.should(
See.the(
BodyOfTheLastResponse()["users"][0]["first_name"],
ReadsExactly("Monty")
),
)
# text response
the_actor.should(
See.the(BodyOfTheLastResponse(), ReadsExactly("To be, or not to be"))
)
# text response, sliced
the_actor.should(
See.the(BodyOfTheLastResponse()[6:12], ReadsExactly("Python"))
)
"""

body_parts: list[str | int]
Expand Down

0 comments on commit 73dbe48

Please sign in to comment.