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

Setting registry in activate sets the default mock's registry for other users of activate #563

Closed
Forty-Bot opened this issue Jun 26, 2022 · 3 comments · Fixed by #564
Closed
Assignees
Labels

Comments

@Forty-Bot
Copy link

Forty-Bot commented Jun 26, 2022

If the registry parameter is ever used in activate, it will "poison" the default registry for other tests. This is illustrated by the below reproducer:

import responses, responses.registries

@responses.activate(registry=responses.registries.OrderedRegistry)
def test_something_else():
    pass

@responses.activate
def test_registry_type():
    assert type(responses.mock.get_registry()) == responses.registries.FirstMatchRegistry

Removing the first activate line will cause the test to pass. The order of uses does not matter. This occurs with and without pytest. This affects responses 0.20 and 0.21 (at least) on python 3.10.2.

@Forty-Bot Forty-Bot changed the title Setting registry in activate sets the default registry for other tests Setting registry in activate sets the default mock's registry for other users of activate Jun 26, 2022
@beliaev-maksim beliaev-maksim self-assigned this Jun 27, 2022
@beliaev-maksim
Copy link
Collaborator

@Forty-Bot
cannot reproduce:
image

@beliaev-maksim
Copy link
Collaborator

looks like order makes a difference

import responses, responses.registries

@responses.activate
def test_registry_type():
    assert type(responses.mock.get_registry()) == responses.registries.FirstMatchRegistry

@responses.activate(registry=responses.registries.OrderedRegistry)
def test_something_else():
    pass

@beliaev-maksim
Copy link
Collaborator

@Forty-Bot
can you try
pip install -U git+https://github.com/beliaev-maksim/responses.git@mbeliaev/reg_fix

and let me know if that fixes the issue on your production code?

markstory pushed a commit that referenced this issue Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants