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..95a01af 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,18 @@ 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 + live_server.app.config["SERVER_NAME"] == "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