From f3dab54e448eddacb2a1726bb944e346ab32efc5 Mon Sep 17 00:00:00 2001 From: kristofers jurevics Date: Wed, 11 Nov 2026 20:37:23 +0200 Subject: [PATCH 1/2] fix live server host mismatch Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/pytest_flask/fixtures.py | 2 +- tests/test_live_server.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pytest_flask/fixtures.py b/src/pytest_flask/fixtures.py index 1fcb097..54e6487 100644 --- a/src/pytest_flask/fixtures.py +++ b/src/pytest_flask/fixtures.py @@ -77,7 +77,7 @@ def test_server_is_up_and_running(live_server): host = cast(str, pytestconfig.getvalue("live_server_host")) # Explicitly set application ``SERVER_NAME`` for test suite - original_server_name = app.config["SERVER_NAME"] or "localhost.localdomain" + original_server_name = app.config["SERVER_NAME"] or host final_server_name = _rewrite_server_name(original_server_name, str(port)) app.config["SERVER_NAME"] = final_server_name diff --git a/tests/test_live_server.py b/tests/test_live_server.py index 3cedd0b..28f6dc4 100755 --- a/tests/test_live_server.py +++ b/tests/test_live_server.py @@ -1,4 +1,5 @@ import os +from urllib.request import urlopen import pytest from flask import url_for @@ -24,15 +25,19 @@ def test_server_listening(self, client, live_server): def test_url_for(self, live_server): assert ( url_for("ping", _external=True) - == "http://localhost.localdomain:%s/ping" % live_server.port + == "http://localhost:%s/ping" % live_server.port ) def test_set_application_server_name(self, live_server): assert ( live_server.app.config["SERVER_NAME"] - == "localhost.localdomain:%d" % live_server.port + == "localhost:%d" % live_server.port ) + def test_live_server_url_is_reachable(self, live_server): + with urlopen(live_server.url("/ping")) as response: + assert response.status == 200 + def test_rewrite_application_server_name(self, appdir): appdir.create_test_module(""" import pytest From d0ef1d4b7b396c70cf3d404f1103044f81128ed1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2026 18:38:01 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_live_server.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_live_server.py b/tests/test_live_server.py index 28f6dc4..95a01af 100755 --- a/tests/test_live_server.py +++ b/tests/test_live_server.py @@ -30,8 +30,7 @@ def test_url_for(self, live_server): def test_set_application_server_name(self, live_server): assert ( - live_server.app.config["SERVER_NAME"] - == "localhost:%d" % live_server.port + live_server.app.config["SERVER_NAME"] == "localhost:%d" % live_server.port ) def test_live_server_url_is_reachable(self, live_server):