diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f5dd021..7c048ff 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,10 +1,15 @@ 1.7.1 ----- -* Fix ``mock`` requirements in Python 2. Thanks `@ghisvail`_ for the report. +* Fix ``mock`` requirements in Python 2. Thanks `@ghisvail`_ for the report (`#101`_). + +**Internal change** + +* Some tests in ``pytest-mock``'s suite are skipped if assertion rewriting is disabled (`#102`_). .. _@ghisvail: https://github.com/ghisvail .. _#101: https://github.com/pytest-dev/pytest-mock/issues/101 +.. _#102: https://github.com/pytest-dev/pytest-mock/issues/102 1.7.0 ----- diff --git a/test_pytest_mock.py b/test_pytest_mock.py index ab93252..f3d65d5 100644 --- a/test_pytest_mock.py +++ b/test_pytest_mock.py @@ -13,6 +13,19 @@ reason='could not make work on pypy') +@pytest.fixture +def needs_assert_rewrite(pytestconfig): + """ + Fixture which skips requesting test if assertion rewrite is disabled (#102) + + Making this a fixture to avoid acessing pytest's config in the global context. + """ + option = pytestconfig.getoption('assertmode') + if option != 'rewrite': + pytest.skip('this test needs assertion rewrite to work but current option ' + 'is "{}"'.format(option)) + + class UnixFS(object): """ Wrapper to os functions to simulate a Unix file system, used for testing @@ -375,6 +388,7 @@ def test_assert_called_once_with_wrapper(mocker): stub.assert_called_once_with("foo") +@pytest.mark.usefixtures('needs_assert_rewrite') def test_assert_called_args_with_introspection(mocker): stub = mocker.stub() @@ -390,6 +404,7 @@ def test_assert_called_args_with_introspection(mocker): stub.assert_called_once_with(*wrong_args) +@pytest.mark.usefixtures('needs_assert_rewrite') def test_assert_called_kwargs_with_introspection(mocker): stub = mocker.stub() @@ -510,6 +525,7 @@ def runpytest_subprocess(testdir, *args): return testdir.runpytest(*args) +@pytest.mark.usefixtures('needs_assert_rewrite') def test_detailed_introspection(testdir): """Check that the "mock_use_standalone" is being used. """