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
Making requests to non-stadard port throws TimeoutError #387
Comments
Problem is not in the port, it is in the registered uri (but, unfortunately, I didn't find it explicitly stated in the documentation). import httpretty
import requests
httpretty.enable()
httpretty.register_uri(httpretty.GET, 'http://fakeuri.com:8080/', body='{"hello":"world"}')
req = requests.get('http://fakeuri.com:8080', timeout=1)
assert req.status_code == 200
assert req.json() == {"hello": "world"} |
Good catch on the trailing |
In fact, there is a workaround in Line 1346 in c9d0ab7
But the regex doesn't work for a uri with a port (so, this issue could be considered as a bug). Maybe it would be better to improve this regex, rather than updating the documentation. Unfortunately, I saw this line only after I'd posted an answer. |
I thought about that after I made the pull request. Feels wrong to have a warning/caveat to usage in that manner. I have tried the following regex and it works: But unfortunately I can't get the tests to run using virtualenv and I get errors in pipenv, probably because my python version is 3.8.7...idk, but I can't chase that down right now. I'll submit a pull request with the new regex once I have time to fiddle with running the tests. |
@ipetepete and @azurkin I'll soon open a PR using your snippets as base. |
Thanks for taking time to report the issues so thoroughly :) |
Fixed in the release |
Python: 3.8.0
httpretty: 0.9.7
What I tried:
What I expected:
What I got:
The text was updated successfully, but these errors were encountered: