Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pytest_flask/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions tests/test_live_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from urllib.request import urlopen

import pytest
from flask import url_for
Expand All @@ -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
Expand Down