diff --git a/PKG-INFO b/PKG-INFO index 1ee9ff6..8733eaf 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pytest-mock -Version: 1.1 +Version: 1.2 Summary: Thin-wrapper around the mock package for easier use with py.test Home-page: https://github.com/pytest-dev/pytest-mock/ Author: Bruno Oliveira @@ -77,6 +77,7 @@ Description: =========== * `PropertyMock `_ * `ANY `_ * `call `_ *(Version 1.1)* + * `sentinel `_ *(Version 1.2)* Spy diff --git a/README.rst b/README.rst index d0d3033..31a6bc6 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.egg-info/PKG-INFO b/pytest_mock.egg-info/PKG-INFO index 1ee9ff6..8733eaf 100644 --- a/pytest_mock.egg-info/PKG-INFO +++ b/pytest_mock.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pytest-mock -Version: 1.1 +Version: 1.2 Summary: Thin-wrapper around the mock package for easier use with py.test Home-page: https://github.com/pytest-dev/pytest-mock/ Author: Bruno Oliveira @@ -77,6 +77,7 @@ Description: =========== * `PropertyMock `_ * `ANY `_ * `call `_ *(Version 1.1)* + * `sentinel `_ *(Version 1.2)* Spy diff --git a/pytest_mock.py b/pytest_mock.py index 7c8ebfc..bbb1973 100644 --- a/pytest_mock.py +++ b/pytest_mock.py @@ -1,14 +1,13 @@ import inspect -import sys import pytest -if sys.version_info >= (3, 3): # pragma: no cover - import unittest.mock as mock_module -else: +try: import mock as mock_module +except ImportError: + import unittest.mock as mock_module -version = '1.1' +version = '1.2' class MockFixture(object): @@ -22,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 3980462..1d55295 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 @@ -455,7 +455,7 @@ def test_monkeypatch_ini(mocker, testdir): assert result.ret == 0 -def test_parse_ini_boolean(testdir): +def test_parse_ini_boolean(): import pytest_mock assert pytest_mock.parse_ini_boolean('True') is True assert pytest_mock.parse_ini_boolean('false') is False