Skip to content

Commit 7e1f7d5

Browse files
committed
Added "mock.sentinel" to the "mocker" fixture for convenience.
1 parent 8f67a4f commit 7e1f7d5

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
to install a newer ``mock`` version from PyPI instead of using the one available in the
66
Python distribution.
77
Thanks `@wcooley`_ for the PR (`#54`_).
8+
* ``mock.sentinel`` is now aliased as ``mocker.sentinel`` for convenience.
89

910
.. _@wcooley: https://github.com/wcooley
1011
.. _#54: https://github.com/pytest-dev/pytest-mock/issues/54

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Some objects from the ``mock`` module are accessible directly from ``mocker`` fo
6969
* `PropertyMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.PropertyMock>`_
7070
* `ANY <https://docs.python.org/3/library/unittest.mock.html#any>`_
7171
* `call <https://docs.python.org/3/library/unittest.mock.html#call>`_ *(Version 1.1)*
72+
* `sentinel <https://docs.python.org/3/library/unittest.mock.html#sentinel>`_ *(Version 1.2)*
7273

7374

7475
Spy

pytest_mock.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class MockFixture(object):
2121
PropertyMock = mock_module.PropertyMock
2222
call = mock_module.call
2323
ANY = mock_module.ANY
24+
sentinel = mock_module.sentinel
2425

2526
def __init__(self):
2627
self._patches = [] # list of mock._patch objects

test_pytest_mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test_deprecated_mock(mock, tmpdir):
132132
assert os.listdir(str(tmpdir)) == []
133133

134134

135-
@pytest.mark.parametrize('name', ['MagicMock', 'PropertyMock', 'Mock', 'call', 'ANY'])
135+
@pytest.mark.parametrize('name', ['MagicMock', 'PropertyMock', 'Mock', 'call', 'ANY', 'sentinel'])
136136
def test_mocker_aliases(name):
137137
from pytest_mock import mock_module, MockFixture
138138

0 commit comments

Comments
 (0)