Skip to content

Commit 9725875

Browse files
committed
Ensure the live_server host is readonly attribute
1 parent cd00669 commit 9725875

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pytest_flask/fixtures.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,15 @@ class LiveServer(object):
5353

5454
def __init__(self, app, port, wait):
5555
self.app = app
56-
self.host = 'localhost'
5756
self.port = port
5857
self.wait = wait
5958
self._process = None
6059

60+
@property
61+
def host(self):
62+
"""Returns the host to run application, e.g. 'localhost'."""
63+
return 'localhost'
64+
6165
def start(self):
6266
"""Start application in a separate process."""
6367
def worker(app, port):

tests/test_live_server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def test_init(self, live_server):
1515
assert live_server.port
1616
assert live_server.host == 'localhost'
1717

18+
def test_host_is_readonly(self, live_server):
19+
with pytest.raises(AttributeError):
20+
live_server.host = 'example.com'
21+
1822
def test_server_is_alive(self, live_server):
1923
assert live_server._process
2024
assert live_server._process.is_alive()

0 commit comments

Comments
 (0)