Skip to content

Export more names from responses in pytest-responses - #30

Open
filbranden wants to merge 1 commit into
getsentry:mainfrom
filbranden:exportmore1
Open

filbranden wants to merge 1 commit into
getsentry:mainfrom
filbranden:exportmore1

Conversation

@filbranden

Copy link
Copy Markdown

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