From 7e1f7d5a51ccf942dbfcb01eb3fd6a80a57ee22c Mon Sep 17 00:00:00 2001 From: Kyle Wilcox Date: Tue, 2 Aug 2016 14:14:20 -0700 Subject: [PATCH] Added "mock.sentinel" to the "mocker" fixture for convenience. --- CHANGELOG.rst | 1 + README.rst | 1 + pytest_mock.py | 1 + test_pytest_mock.py | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index dbd3fd9..e4b8953 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 diff --git a/README.rst b/README.rst index 4e1dc3b..2477c11 100644 --- a/README.rst +++ b/README.rst @@ -69,6 +69,7 @@ Some objects from the ``mock`` module are accessible directly from ``mocker`` fo * `PropertyMock `_ * `ANY `_ * `call `_ *(Version 1.1)* +* `sentinel `_ *(Version 1.2)* Spy diff --git a/pytest_mock.py b/pytest_mock.py index 6e9d011..8088432 100644 --- a/pytest_mock.py +++ b/pytest_mock.py @@ -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 diff --git a/test_pytest_mock.py b/test_pytest_mock.py index c999cd3..1e47d0e 100644 --- a/test_pytest_mock.py +++ b/test_pytest_mock.py @@ -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