Skip to content
New issue

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

Added "mock.sentinel" to the "mocker" fixture for convenience. #56

Merged
merged 1 commit into from
Aug 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
to install a newer ``mock`` version from PyPI instead of using the one available in the
Python distribution.
Thanks `@wcooley`_ for the PR (`#54`_).
* ``mock.sentinel`` is now aliased as ``mocker.sentinel`` for convenience.

.. _@wcooley: https://github.com/wcooley
.. _#54: https://github.com/pytest-dev/pytest-mock/issues/54
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Some objects from the ``mock`` module are accessible directly from ``mocker`` fo
* `PropertyMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.PropertyMock>`_
* `ANY <https://docs.python.org/3/library/unittest.mock.html#any>`_
* `call <https://docs.python.org/3/library/unittest.mock.html#call>`_ *(Version 1.1)*
* `sentinel <https://docs.python.org/3/library/unittest.mock.html#sentinel>`_ *(Version 1.2)*


Spy
Expand Down
1 change: 1 addition & 0 deletions pytest_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MockFixture(object):
PropertyMock = mock_module.PropertyMock
call = mock_module.call
ANY = mock_module.ANY
sentinel = mock_module.sentinel

def __init__(self):
self._patches = [] # list of mock._patch objects
Expand Down
2 changes: 1 addition & 1 deletion test_pytest_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_deprecated_mock(mock, tmpdir):
assert os.listdir(str(tmpdir)) == []


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

Expand Down