adding the ability to set the host on the flask app for using a remot…#126
Open
dhrod5 wants to merge 1 commit intojarus:masterfrom
Open
adding the ability to set the host on the flask app for using a remot…#126dhrod5 wants to merge 1 commit intojarus:masterfrom
dhrod5 wants to merge 1 commit intojarus:masterfrom
Conversation
…e selenium server
nelsnelson
approved these changes
Jan 4, 2019
nelsnelson
suggested changes
Jan 4, 2019
| 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.
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,
)
nelsnelson
reviewed
Jan 4, 2019
| 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.
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.
And of course https://github.com/jarus/flask-testing/pull/126/files#diff-171a436f5b46787445201095ddb2db3fR463 will have to become
def worker(app, host, port):
nelsnelson
suggested changes
Jan 4, 2019
nelsnelson
suggested changes
Jan 4, 2019
| 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.
And of course https://github.com/jarus/flask-testing/pull/126/files#diff-171a436f5b46787445201095ddb2db3fR463 will have to become
def worker(app, host, port):
nelsnelson
reviewed
Jan 4, 2019
|
|
||
| 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.
Parameterize the worker method so that this can be simply host=host.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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' )