-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding the ability to set the host on the flask app for using a remot… #126
base: master
Are you sure you want to change the base?
Conversation
…e selenium server
@@ -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) |
There was a problem hiding this comment.
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,
)
@@ -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) | |||
|
|||
self._process = multiprocessing.Process( | |||
target=worker, args=(self.app, self._configured_port) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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) | |||
|
|||
self._process = multiprocessing.Process( | |||
target=worker, args=(self.app, self._configured_port) |
There was a problem hiding this comment.
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):
@@ -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) |
There was a problem hiding this comment.
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
.
…e selenium server
My usecase was that I wanted to have testing done using docker compose and selenium/standalone-chrome. Since they run in different containers you need to bind the host to 0.0.0.0 or the selenium container cannot access the LiveServer.
These changes allow you to configure your app to change the host that the LiveServer starts on like this:
def create_app(self): app.config.update( LIVESERVER_PORT=8943, LIVESERVER_HOST='0.0.0.0' )