Skip to content

Commit a351c4d

Browse files
committed
[py] require --use-lan-ip flag to start test server on non-local host
1 parent 24c2c4f commit a351c4d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

py/conftest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ def pytest_addoption(parser):
7474
dest="headless",
7575
help="Allow tests to run in headless",
7676
)
77+
parser.addoption(
78+
"--use-lan-ip",
79+
action="store_true",
80+
dest="use_lan_ip",
81+
help="Whether to start test server with lan ip instead of localhost",
82+
)
7783

7884

7985
def pytest_ignore_collect(path, config):
@@ -287,8 +293,10 @@ def wait_for_server(url, timeout):
287293

288294

289295
@pytest.fixture(autouse=True, scope="session")
290-
def webserver():
291-
webserver = SimpleWebServer(host=get_lan_ip())
296+
def webserver(request):
297+
host = get_lan_ip() if request.config.getoption("use_lan_ip") else "0.0.0.0"
298+
299+
webserver = SimpleWebServer(host=host)
292300
webserver.start()
293301
yield webserver
294302
webserver.stop()

0 commit comments

Comments
 (0)