Skip to content

Commit 9e1464b

Browse files
coiaxnicoddemus
andauthored
🦭 Add seal shortcut to mocker fixture (#211)
Co-authored-by: Bruno Oliveira <[email protected]>
1 parent bd8f613 commit 9e1464b

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
3.4.0 (UNRELEASED)
2+
------------------
3+
4+
* Add `mock.seal` alias to the `mocker` fixture (`#211`_). Thanks `@coiax`_ for the PR.
5+
6+
.. _@coiax: https://github.com/coiax
7+
.. _#211: https://github.com/pytest-dev/pytest-mock/pull/211
8+
19
3.3.1 (2020-08-24)
210
------------------
311

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Also, as a convenience, these names from the ``mock`` module are accessible dire
8181
* `call <https://docs.python.org/3/library/unittest.mock.html#call>`_ *(Version 1.1)*
8282
* `sentinel <https://docs.python.org/3/library/unittest.mock.html#sentinel>`_ *(Version 1.2)*
8383
* `mock_open <https://docs.python.org/3/library/unittest.mock.html#mock-open>`_
84+
* `seal <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.seal>`_ *(Version 3.4)*
8485

8586
It is also possible to use mocking functionality from fixtures of other scopes using
8687
the appropriate mock fixture:

src/pytest_mock/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def __init__(self, config: Any) -> None:
6565
self.create_autospec = mock_module.create_autospec
6666
self.sentinel = mock_module.sentinel
6767
self.mock_open = mock_module.mock_open
68+
if hasattr(mock_module, "seal"):
69+
self.seal = mock_module.seal
6870

6971
def resetall(self) -> None:
7072
"""Call reset_mock() on all patchers started by this fixture."""

tests/test_pytest_mock.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ def test_mock_patch_dict_resetall(mocker: MockerFixture) -> None:
152152
"NonCallableMock",
153153
"PropertyMock",
154154
"sentinel",
155+
pytest.param(
156+
"seal",
157+
marks=pytest.mark.skipif(
158+
sys.version_info < (3, 7), reason="seal is present on 3.7 and above"
159+
),
160+
),
155161
],
156162
)
157163
def test_mocker_aliases(name: str, pytestconfig: Any) -> None:

0 commit comments

Comments
 (0)