diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 222182e..04a08da 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,11 @@ +3.4.0 (UNRELEASED) +------------------ + +* Add `mock.seal` alias to the `mocker` fixture (`#211`_). Thanks `@coiax`_ for the PR. + +.. _@coiax: https://github.com/coiax +.. _#211: https://github.com/pytest-dev/pytest-mock/pull/211 + 3.3.1 (2020-08-24) ------------------ diff --git a/README.rst b/README.rst index 5776a47..5bf09a9 100644 --- a/README.rst +++ b/README.rst @@ -81,6 +81,7 @@ Also, as a convenience, these names from the ``mock`` module are accessible dire * `call `_ *(Version 1.1)* * `sentinel `_ *(Version 1.2)* * `mock_open `_ +* `seal `_ *(Version 3.4)* It is also possible to use mocking functionality from fixtures of other scopes using the appropriate mock fixture: diff --git a/src/pytest_mock/plugin.py b/src/pytest_mock/plugin.py index 6ee2ed7..c9f3853 100644 --- a/src/pytest_mock/plugin.py +++ b/src/pytest_mock/plugin.py @@ -65,6 +65,8 @@ def __init__(self, config: Any) -> None: self.create_autospec = mock_module.create_autospec self.sentinel = mock_module.sentinel self.mock_open = mock_module.mock_open + if hasattr(mock_module, "seal"): + self.seal = mock_module.seal def resetall(self) -> None: """Call reset_mock() on all patchers started by this fixture.""" diff --git a/tests/test_pytest_mock.py b/tests/test_pytest_mock.py index 129bc88..33a80b2 100644 --- a/tests/test_pytest_mock.py +++ b/tests/test_pytest_mock.py @@ -152,6 +152,12 @@ def test_mock_patch_dict_resetall(mocker: MockerFixture) -> None: "NonCallableMock", "PropertyMock", "sentinel", + pytest.param( + "seal", + marks=pytest.mark.skipif( + sys.version_info < (3, 7), reason="seal is present on 3.7 and above" + ), + ), ], ) def test_mocker_aliases(name: str, pytestconfig: Any) -> None: