We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
mocker.Mock | mocker.MagicMock
I want to be able to import Mock and MagicMock types for type annotations.
Mock
MagicMock
I don't want to have to import from unittest.mock because I am enforcing the use of pytest-mock by banning the import of unittest.mock.
unittest.mock
pytest-mock
from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from pytest_mock import Mock, MagicMock, MockerFixture @pytest.fixtue def my_mock(mocker: MockerFixture) -> Mock: return mocker.Mock() @pytest.fixtue def my_magic_mock(mocker: MockerFixture) -> MagicMock: return mocker.MagicMock() def test_something(my_mock: Mock): ...
I see 2 different approaches here.
__init__
pytest_mock.types
ANY
1 could be an issue because it might encourage users to use the Mock/Mocker as more than just type-annotations.
1
Mocker
The text was updated successfully, but these errors were encountered:
MockType
Export MockType/AsyncMockType for type annotations (#415)
AsyncMockType
366966b
Fix #414 --------- Co-authored-by: Bruno Oliveira <[email protected]>
Successfully merging a pull request may close this issue.
I want to be able to import
Mock
andMagicMock
types for type annotations.I don't want to have to import from
unittest.mock
because I am enforcing the use ofpytest-mock
by banning the import ofunittest.mock
.I see 2 different approaches here.
unittest.mock
Mock
+MagicMock
in the top-level__init__
filepytest_mock.types
subpackage. This could also include things likeANY
which would otherwise need to be imported fromunittest.mock
.1
could be an issue because it might encourage users to use theMock
/Mocker
as more than just type-annotations.The text was updated successfully, but these errors were encountered: