Skip to content
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

Plugin testing documentation on using pytest-httpx #1198

Closed
simonw opened this issue Jan 23, 2021 · 1 comment
Closed

Plugin testing documentation on using pytest-httpx #1198

simonw opened this issue Jan 23, 2021 · 1 comment

Comments

@simonw
Copy link
Owner

simonw commented Jan 23, 2021

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.

@simonw
Copy link
Owner Author

simonw commented Jan 24, 2021

This was referenced Jan 25, 2021
simonw added a commit that referenced this issue Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant