-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Improve parse_address utils tests #1629
Improve parse_address utils tests #1629
Conversation
tests/test_util.py
Outdated
from gunicorn import util | ||
|
||
|
||
def test_parse_address(): | ||
def test_parse_address(capsys): |
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.
Seems unused. Is it needed?
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.
Looks good, but if capsys
isn't used we can remove it. Otherwise great!
tests/test_util.py
Outdated
|
||
with pytest.raises(RuntimeError) as err: | ||
assert util.parse_address('127.0.0.1:test') | ||
assert err.value.message == "'test' is not a valid port number." |
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.
This will raise an AttributeError
under Python 3. I'd use str(exc)
instead.
tests/test_util.py
Outdated
# Test unix socket addresses (PR #1623) | ||
assert util.parse_address('unix://var/run/test.sock') == 'var/run/test.sock' | ||
assert util.parse_address('unix:/var/run/test.sock') == '/var/run/test.sock' | ||
|
||
assert util.parse_address('') == ('0.0.0.0', 8000) |
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.
We could turn this test to use pytest.mark.parametrize
: https://docs.pytest.org/en/latest/parametrize.html#pytest-mark-parametrize
04404f3
to
d2d0edb
Compare
@berkerpeksag, thanks. it is ok for use pytest.mark.parametrize , but how do I test RuntimeError with pytest.mark.parametrize? |
I'd move it to a separate test function (e.g. |
d2d0edb
to
56cc113
Compare
56cc113
to
13df156
Compare
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.
Looks great, thank you! I just made some trivial style changes and will merge this once Travis is passed.
No description provided.