Skip to content

Commit 866792f

Browse files
committed
Add note into documentation about available options
1 parent a728592 commit 866792f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/features.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,41 @@ other headless browsers).
139139
assert res.code == 200
140140
141141
142+
``--start-live-server`` - start live server automatically (default)
143+
```````````````````````````````````````````````````````````````````
144+
145+
146+
``--no-start-live-server`` - don't start live server automatically
147+
``````````````````````````````````````````````````````````````````
148+
149+
By default the server is starting automatically whenever you reference
150+
``live_server`` fixture in your tests. But starting live server imposes some
151+
high costs on tests that need it when they may not be ready yet. To prevent
152+
that behaviour pass ``--no-start-live-server`` into your default options (for
153+
example, in your project's ``pytest.ini`` file)::
154+
155+
[pytest]
156+
addopts = --no-start-live-server
157+
158+
.. note::
159+
160+
Your **should manually start** live server after you finish your application
161+
configuration and define all required routes:
162+
163+
.. code:: python
164+
165+
def test_add_endpoint_to_live_server(live_server):
166+
@live_server.app.route('/test-endpoint')
167+
def test_endpoint():
168+
return 'got it', 200
169+
170+
live_server.start()
171+
172+
res = urlopen(url_for('test_endpoint', _external=True))
173+
assert res.code == 200
174+
assert b'got it' in res.read()
175+
176+
142177
``request_ctx`` - request context
143178
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
144179

0 commit comments

Comments
 (0)