File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments