Skip to content

Commit

Permalink
Add docs for reponse file loading(#590)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Story <mark@mark-story.com>
  • Loading branch information
beliaev-maksim and markstory authored Sep 21, 2022
1 parent 3bb694b commit b3caf4c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,31 @@ will produce next output:
content_type = "text/plain"
auto_calculate_content_length = false
Replay responses (populate registry) from files
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You can populate your active registry from a ``toml`` file with recorded responses.
(See `Record Responses to files`_ to understand how to obtain a file).
To do that you need to execute ``responses._add_from_file(file_path="out.toml")`` within
an activated decorator or a context manager.

The following code example registers a ``patch`` response, then all responses present in
``out.toml`` file and a ``post`` response at the end.

.. code-block:: python
import responses
@responses.activate
def run():
responses.patch("http://httpbin.org")
responses._add_from_file(file_path="out.toml")
responses.post("http://httpbin.org/form")
run()
Basics
------

Expand Down

0 comments on commit b3caf4c

Please sign in to comment.