Skip to content
Open
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
5 changes: 3 additions & 2 deletions flask_testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ def __call__(self, result=None):
# Get the app
self.app = self.create_app()

self._configured_host = self.app.config.get('LIVESERVER_HOST', 'localhost')
self._configured_port = self.app.config.get('LIVESERVER_PORT', 5000)
self._port_value = multiprocessing.Value('i', self._configured_port)

Expand All @@ -453,7 +454,7 @@ def get_server_url(self):
"""
Return the url of the test server
"""
return 'http://localhost:%s' % self._port_value.value
return 'http://{}:{}'.format(self._configured_host, self._port_value.value)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To pass python2.6 testing, line should be apparently something more like

return 'http://{hostname}:{port}'.format(
    hostname=self._configured_host,
    port=self._port_value.value,
)


def _spawn_live_server(self):
self._process = None
Expand All @@ -477,7 +478,7 @@ def socket_bind_wrapper(self):
return ret

socketserver.TCPServer.server_bind = socket_bind_wrapper
app.run(port=port, use_reloader=False)
app.run(port=port, use_reloader=False, host=self._configured_host)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameterize the worker method so that this can be simply host=host.


self._process = multiprocessing.Process(
target=worker, args=(self.app, self._configured_port)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably also add the parameters here:

self._process = multiprocessing.Process(
    target=worker, args=(self.app, self._configured_host, self._configured_port)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And of course https://github.com/jarus/flask-testing/pull/126/files#diff-171a436f5b46787445201095ddb2db3fR463 will have to become

def worker(app, host, port):

Expand Down