Add all the necessary imports in the code examples in the doc
joaompinto opened this issue · 2 comments
joaompinto commented
In some snippets the documentation provides the import statement for requests but not for the HTTPServer object, adding all the required imports should make the documentation more clear and easier to use specially for new users.
Example:
Current:
import requests
def test_json_client(httpserver: HTTPServer):
httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"})
assert requests.get(httpserver.url_for("/foobar")).json() == {"foo": "bar"}
Proposed:
import requests
from pytest_httpserver import HTTPServer
def test_json_client(httpserver: HTTPServer):
httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"})
assert requests.get(httpserver.url_for("/foobar")).json() == {"foo": "bar"}
csernazs commented
Hi,
There's a PR #192 which moves the examples out of doc to a directory so it also fixes the imports you were mentioning. Also, a bunch of examples were invalid so those are also fixed.
Could you please look at it?
If that's acceptable for you, I would merge #192 instead of yours. I think I just forgot to merge it.
Thanks,
Zsolt
joaompinto commented
Hi,
sorry, missed that pending PR.
Looks good to me, thanks the quick answer.