Fix output of test_lowlevel tests in case of timeout #6136
Merged
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.
Hello,
The tests in
test_lowlevel.py
use thetestserver.server.Server
thread object.When using the object as a context manager, we wait until the server thread is ready with a timeout.
Unfortunately, if the timeout is reached, we would not propagate the error. Instead, we would return from the
__enter__
method and access thewith
body with an uninitialized value forport
(i.e.,port = 0
).Therefore, the tests would fail with:
Reading this error does not make it obvious that this is the result of a timeout.
Fixed by raising an error in case of timeout, which makes it more obvious:
The reason why I had a timeout on my end was because my environment was not resolving "localhost" as it should have. Requests were going through the DNS and therefore ended-up hitting the timeout
The name resolution taking forever was happening during this instruction (where
self.host
islocalhost
):Thanks,
Olivier