Skip to content

Plugin testing documentation on using pytest-httpx #1198

@simonw

Description

@simonw

I keep on having to figure this out: if you use the https://pypi.org/project/pytest-httpx/ fixture to write tests against mocked external APIs, they will fail because that module will break Datasette's own datasette.client testing mechanism.

You can fix this using:

@pytest.fixture
def non_mocked_hosts():
    return ["localhost"]

See https://github.com/simonw/datasette-indieauth/blob/1.2/tests/test_indieauth.py

I can add this tip to the https://docs.datasette.io/en/stable/testing_plugins.html page.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions