Skip to content

Commit 1595ed5

Browse files
committed
doc/guide: improve documentation
* Clarify port specification * Add more information about server lifetime when using from pytest
1 parent f0db4a4 commit 1595ed5

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

doc/guide.rst

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,27 @@ The server can be started by instatiating it and then calling the
99
thread, so you will need to make sure that the :py:meth:`pytest_httpserver.HTTPServer.stop` method
1010
is called before your code exits.
1111

12-
A free TCP port needs to be specified when instantiating the server, where no other daemon is listening.
12+
When using the pytest plugin, the server is started at the first usage of the server and it will
13+
remain running for the whole test suite. For each test function, a clear http server will be used
14+
to avoid crosstalk.
1315

14-
If you are using the pytest plugin it is done automatically by the plugin. Possibility to change
15-
the TCP port is TBD.
16+
A free TCP port needs to be specified when instantiating the server. Setting 0 as the port number
17+
will select a free (ephemeral) TCP port which is guaranteed to be free.
18+
This is the default behavior.
1619

17-
When using pytest plugin, specifying the bind address and bind port can also be possible via environment
18-
variables. Setting PYTEST_HTTPSERVER_HOST and PYTEST_HTTPSERVER_PORT will change the bind host and bind
19-
port, respectively.
20+
Specifying the bind host and port can be done in several ways:
21+
22+
* Setting PYTEST_HTTPSERVER_HOST and PYTEST_HTTPSERVER_PORT will change the bind host and bind
23+
port, respectively.
24+
25+
* If pytest plugin is not used, the DEFAULT_LISTEN_HOST and DEFAULT_LISTEN_PORT class attributes can be set
26+
on the HTTPServer class.
27+
28+
* bind host and port can be specified for the constructor of the
29+
:py:class:`pytest_httpserver.server.HTTPServer` class.
30+
31+
* Overriding the ``httpserver_listen_address`` fixture in pytest.
2032

21-
If pytest plugin is not used, the DEFAULT_LISTEN_HOST and DEFAULT_LISTEN_PORT class attributes can be set
22-
on the HTTPServer class.
2333

2434
Configuring
2535
-----------

0 commit comments

Comments
 (0)