Skip to content

Commit b374235

Browse files
committed
doc: add notes about defining responses for the expected requests
1 parent 2aa9d27 commit b374235

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

doc/tutorial.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ This tells that when the request arrives to the *http://localhost/foobar* URL,
3939
it must respond with the provided json. The library accepts here any python
4040
object which is json serializable. Here, a dict is provided.
4141

42+
.. note::
43+
44+
It is important to specify what response to be sent back to the client
45+
otherwise *pytest-httpserver* will error with ``Matching request handler
46+
found but no response defined`` message on an incoming request.
47+
4248
In the next line, an http request is sent with the *requests* library:
4349

4450
.. code:: python

pytest_httpserver/httpserver.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,15 @@ def expect_request(
971971
If `handler_type` is `HandlerType.ORDERED` an ordered request handler is created. Comparing to oneshot handler,
972972
ordered handler also determines the order of the requests to be served. For example if there are two ordered
973973
handlers registered, the first request must hit the first handler, and the second request must hit the second
974-
one, and not vice versa. If one or more ordered handler defined, those must be exhausted first.
974+
one, and not vice versa. If one or more ordered handler defined, those
975+
must be exhausted first.
976+
977+
.. note::
978+
979+
Once this method is called, the response should also be specified by
980+
calling one of the respond methods of the returned
981+
:py:class:`RequestHandler` object, otherwise
982+
:py:class:`NoHandlerError` will be raised on an incoming request.
975983
976984
977985
:param uri: URI of the request. This must be an absolute path starting with ``/``, a

0 commit comments

Comments
 (0)