Skip to content

Commit

Permalink
doc: add notes about defining responses for the expected requests
Browse files Browse the repository at this point in the history
  • Loading branch information
csernazs committed Jan 5, 2024
1 parent 2aa9d27 commit b374235
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doc/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ This tells that when the request arrives to the *http://localhost/foobar* URL,
it must respond with the provided json. The library accepts here any python
object which is json serializable. Here, a dict is provided.

.. note::

It is important to specify what response to be sent back to the client
otherwise *pytest-httpserver* will error with ``Matching request handler
found but no response defined`` message on an incoming request.

In the next line, an http request is sent with the *requests* library:

.. code:: python
Expand Down
10 changes: 9 additions & 1 deletion pytest_httpserver/httpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,15 @@ def expect_request(
If `handler_type` is `HandlerType.ORDERED` an ordered request handler is created. Comparing to oneshot handler,
ordered handler also determines the order of the requests to be served. For example if there are two ordered
handlers registered, the first request must hit the first handler, and the second request must hit the second
one, and not vice versa. If one or more ordered handler defined, those must be exhausted first.
one, and not vice versa. If one or more ordered handler defined, those
must be exhausted first.
.. note::
Once this method is called, the response should also be specified by
calling one of the respond methods of the returned
:py:class:`RequestHandler` object, otherwise
:py:class:`NoHandlerError` will be raised on an incoming request.
:param uri: URI of the request. This must be an absolute path starting with ``/``, a
Expand Down

0 comments on commit b374235

Please sign in to comment.