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

Export more names from responses in pytest-responses #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

filbranden
Copy link

This makes it easier to use the names, since the fixture name responses clashes with the module import.

For example, it is possible to add a type annotation to a pytest module using the responses fixture:

def test_my_request(responses: pytest_responses.RequestsMock) -> None:
    ...

It is also possible to access matchers via pytest_responses.matchers, also assemble a Response object, use registries, etc.

See related getsentry/responses#739 for exporting more under RequestsMock as well, and recommending use of this pytest-responses plug-in for a standard pytest fixture for responses.

Also update to accessing default start/stop/reset via the requests.mock object, and using the @pytest.fixtures decorator since @yield_fixture has been long deprecated.

This makes it easier to use the names, since the fixture name `responses` clashes with the module import.

For example, it is possible to add a type annotation to a pytest module using the responses fixture:

```
def test_my_request(responses: pytest_responses.RequestsMock) -> None:
    ...
```

It is also possible to access matchers via pytest_responses.matchers, also assemble a Response object, use registries, etc.

Also update to accessing default start/stop/reset via the `requests.mock` object, and using the `@pytest.fixtures` decorator since `@yield_fixture` has been long deprecated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants