Skip to content

Add all the necessary imports in the code examples in the doc #204

Closed

Description

@joaompinto

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"}

Activity

  1. added a commit that references this issue on Jan 21, 2023
    09589a8
  2. csernazs commented on Jan 21, 2023

    @csernazs
    Owner

    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

  3. joaompinto commented on Jan 21, 2023

    @joaompinto
    Author

    Hi,
    sorry, missed that pending PR.

    Looks good to me, thanks the quick answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions