Skip to content

Avoid issues between pytest-mock and other fixtures #586

Description

@kasium

Background: in a closed-source project I had the case that a mock established in a test interfered with a fixture teardown using the mocked method

Given a test (1) using pytest-mock and another fixture(2), if 1 mocks a method and 2 then wants to use it, I depend on the pytest fixture order whether the mocker teardown runs before or after 2 leading to issues.

Of course there are partly solutions like explicit fixture order by require them in a bundle fixture or by storing the method in a variable before the test starts but all of them are only partly solutions or are cumbersome.

It would be great if pytest-mock could give an guarantee that the mocks are removed right after the test function ran. Is there any option

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions