-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Raise TypeError if port is not an integer #1088
Conversation
tests/test_serving.py
Outdated
|
||
|
||
def test_port_must_be_integer(dev_server): | ||
with pytest.raises(TypeError) as port_type_exception: |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
tests/test_serving.py
Outdated
|
||
def test_port_must_be_integer(dev_server): | ||
with pytest.raises(TypeError) as port_type_exception_with_reloader: | ||
def app(environ, start_response): |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Thanks for your review @JordanP and @untitaker . The new test is ready and works 👌 |
tests/test_serving.py
Outdated
start_response('200 OK', [('Content-Type', 'text/html')]) | ||
return [b'hello'] | ||
|
||
with pytest.raises(TypeError) as port_type_exception_with_reloader: |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Please rebase and add a changelog to version 0.13. 0.12-maintenance is really just for bugfixes, but this actually changes behavior. |
Ports should be integers, so a type check is explicitly added to raise an exception when this is ignored. This inappropiate behaviour was detected when using `debug=True` in a Flask application, because a string is accepted and works when it should fail. Closes pallets/flask#2220 Signed-off-by: Antonio Ossa <[email protected]>
This testcase tries to use a string as port parameter, which should not be allowed by `run_simple`. The test uses `run_simple` directly because the tests configuration raises the error in a different process without giving a chance to catch the `TypeError` exception. See pallets/flask#2220 Signed-off-by: Antonio Ossa <[email protected]>
Signed-off-by: Antonio Ossa <[email protected]>
I think I've done it 👌 Do you have more issues or PRs to read/work on? 😁 |
Thanks! |
Regarding your question, I think everything labelled with "beginner ready" would work |
As explained in pallets/flask#2220
port
should be an integer and in other cases aTypeError
exception should be raised. This PR includes a type check to raise said exception and a test to check if the exception is raised (whenuse_reloader
isTrue
and when itsFalse
).Closes pallets/flask#2220