Hello community, here is the log from the commit of package python-pytest-mock for openSUSE:Factory checked in at 2019-10-07 13:39:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-mock (Old) and /work/SRC/openSUSE:Factory/.python-pytest-mock.new.2352 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-mock" Mon Oct 7 13:39:38 2019 rev:14 rq:734062 version:1.11.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-mock/python-pytest-mock.changes 2019-09-23 12:06:36.949913241 +0200 +++ /work/SRC/openSUSE:Factory/.python-pytest-mock.new.2352/python-pytest-mock.changes 2019-10-07 13:39:39.508569584 +0200 @@ -1,0 +2,8 @@ +Mon Sep 30 12:22:25 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 1.11.0: + * The object returned by mocker.spy now also tracks the return + value of the spied method/function. +- Drop merged patch mock3.patch and fix_tests.patch + +------------------------------------------------------------------- Old: ---- fix_tests.patch mock3.patch pytest-mock-1.10.4.tar.gz New: ---- pytest-mock-1.11.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-mock.spec ++++++ --- /var/tmp/diff_new_pack.mk3nox/_old 2019-10-07 13:39:40.028568147 +0200 +++ /var/tmp/diff_new_pack.mk3nox/_new 2019-10-07 13:39:40.028568147 +0200 @@ -20,15 +20,13 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %bcond_without python2 Name: python-pytest-mock -Version: 1.10.4 +Version: 1.11.0 Release: 0 Summary: Thin-wrapper around the mock package for easier use with pytest License: MIT Group: Development/Languages/Python URL: https://github.com/pytest-dev/pytest-mock Source: https://files.pythonhosted.org/packages/source/p/pytest-mock/pytest-mock-%{version}.tar.gz -Patch0: mock3.patch -Patch1: fix_tests.patch BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools >= 36} BuildRequires: %{python_module setuptools_scm} @@ -52,7 +50,6 @@ %prep %setup -q -n pytest-mock-%{version} -%autopatch -p1 %build %python_build ++++++ pytest-mock-1.10.4.tar.gz -> pytest-mock-1.11.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/.github/FUNDING.yml new/pytest-mock-1.11.0/.github/FUNDING.yml --- old/pytest-mock-1.10.4/.github/FUNDING.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-mock-1.11.0/.github/FUNDING.yml 2019-09-28 20:53:36.000000000 +0200 @@ -0,0 +1,4 @@ +# info: +# * https://help.github.com/en/articles/displaying-a-sponsor-button-in-your-repository +# * https://tidelift.com/subscription/how-to-connect-tidelift-with-github +tidelift: pypi/pytest-mock diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/.github/workflows/main.yml new/pytest-mock-1.11.0/.github/workflows/main.yml --- old/pytest-mock-1.10.4/.github/workflows/main.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-mock-1.11.0/.github/workflows/main.yml 2019-09-28 20:53:36.000000000 +0200 @@ -0,0 +1,82 @@ +name: build + +on: [push, pull_request] + +jobs: + build: + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + python: ["2.7", "3.5", "3.6", "3.7"] + os: [ubuntu-latest, windows-latest] + include: + - python: "2.7" + tox_env: "py27" + - python: "3.5" + tox_env: "py35" + - python: "3.6" + tox_env: "py36" + - python: "3.7" + tox_env: "py37" + + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python }} + - name: Install tox + run: | + python -m pip install --upgrade pip + pip install tox + - name: Test + run: | + tox -e ${{ matrix.tox_env }} + + linting: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: "3.7" + - name: Install tox + run: | + python -m pip install --upgrade pip + pip install tox + - name: Linting + run: | + tox -e linting + + deploy: + + runs-on: ubuntu-latest + + needs: [build, linting] + + + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: "3.7" + - name: Install wheel + run: | + python -m pip install --upgrade pip + pip install wheel + - name: Build package + run: | + python setup.py sdist bdist_wheel + - name: Publish package to PyPI + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.pypi_token }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/.travis.yml new/pytest-mock-1.11.0/.travis.yml --- old/pytest-mock-1.10.4/.travis.yml 2019-04-17 19:23:43.000000000 +0200 +++ new/pytest-mock-1.11.0/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,50 +0,0 @@ -language: python -dist: xenial - -install: - - pip install -U pip - - pip install tox coveralls - -script: - - tox - -after_success: - - coveralls - -stages: -- test -- name: deploy - if: repo = pytest-dev/pytest-mock AND tag IS present - -jobs: - include: - - python: '2.7' - env: TOXENV=py27 - - python: '3.4' - env: TOXENV=py34 - - python: '3.5' - env: TOXENV=py35 - - python: '3.6' - env: TOXENV=py36 - - python: '3.7' - env: TOXENV=py37 - - python: '3.8-dev' - env: TOXENV=py38 - - python: '3.6' - env: TOXENV=linting - - python: '3.6' - env: TOXENV=norewrite - - stage: deploy - python: '3.6' - install: pip install -U setuptools setuptools_scm - script: skip - deploy: - provider: pypi - user: nicoddemus - skip_upload_docs: true - distributions: sdist bdist_wheel - password: - secure: OEWrbk09CZRrwFE6sBpRqQHu45zRu1S0Ly1ZeprkFCKxMd9tZOnrYM5qxCDQXxFHIvuyajuJ+qWTOgxUvurQMNsD6DbvJKTJ0R8upH1b1Q95KK8xiJFedhqBEUga5GrInK59oo0Sgblse2jtH5NnHXRUClSdT+iHdLY5sljCTRg= - on: - tags: true - repo: pytest-dev/pytest-mock diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/CHANGELOG.rst new/pytest-mock-1.11.0/CHANGELOG.rst --- old/pytest-mock-1.10.4/CHANGELOG.rst 2019-04-17 19:23:43.000000000 +0200 +++ new/pytest-mock-1.11.0/CHANGELOG.rst 2019-09-28 20:53:36.000000000 +0200 @@ -1,3 +1,9 @@ +1.11.0 +------ + +* The object returned by ``mocker.spy`` now also tracks the return value + of the spied method/function. + 1.10.4 ------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/PKG-INFO new/pytest-mock-1.11.0/PKG-INFO --- old/pytest-mock-1.10.4/PKG-INFO 2019-04-17 19:24:00.000000000 +0200 +++ new/pytest-mock-1.11.0/PKG-INFO 2019-09-28 20:53:46.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pytest-mock -Version: 1.10.4 +Version: 1.11.0 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 @@ -32,7 +32,7 @@ - |python| |version| |anaconda| |ci| |appveyor| |coverage| |black| + |python| |version| |anaconda| |ci| |coverage| |black| .. |version| image:: http://img.shields.io/pypi/v/pytest-mock.svg :target: https://pypi.python.org/pypi/pytest-mock @@ -40,11 +40,8 @@ .. |anaconda| image:: https://img.shields.io/conda/vn/conda-forge/pytest-mock.svg :target: https://anaconda.org/conda-forge/pytest-mock - .. |ci| image:: http://img.shields.io/travis/pytest-dev/pytest-mock.svg - :target: https://travis-ci.org/pytest-dev/pytest-mock - - .. |appveyor| image:: https://ci.appveyor.com/api/projects/status/pid1t7iuwhkm9eh6/branch/master?svg=true - :target: https://ci.appveyor.com/project/pytestbot/pytest-mock + .. |ci| image:: https://github.com/pytest-dev/pytest-mock/workflows/build/badge.svg + :target: https://github.com/pytest-dev/pytest-mock/actions .. |coverage| image:: http://img.shields.io/coveralls/pytest-dev/pytest-mock.svg :target: https://coveralls.io/r/pytest-dev/pytest-mock @@ -96,10 +93,9 @@ Spy --- - The spy acts exactly like the original method in all cases, except it allows use of `mock` + The spy acts exactly like the original method in all cases, except it allows use of ``mock`` features with it, like retrieving call count. It also works for class and static methods. - .. code-block:: python def test_spy(mocker): @@ -112,6 +108,9 @@ assert foo.bar() == 42 assert foo.bar.call_count == 1 + Since version ``1.11``, it is also possible to query the ``return_value`` attribute + to observe what the spied function/method returned. + Stub ---- @@ -206,6 +205,23 @@ Python 3.4+. Note that this option is only used in Python 3+, as Python 2 users only have the option to use the ``mock`` package from PyPI anyway. + Note about usage as context manager + ----------------------------------- + + Although mocker's API is intentionally the same as ``mock.patch``'s, its use + as context manager and function decorator is **not** supported through the + fixture: + + .. code-block:: python + + def test_context_manager(mocker): + a = A() + with mocker.patch.object(a, 'doIt', return_value=True, autospec=True): # DO NOT DO THIS + assert a.doIt() == True + + The purpose of this plugin is to make the use of context managers and + function decorators for mocking unnecessary. + Requirements ============ @@ -285,47 +301,29 @@ naming fixtures as parameters, or ``pytest.mark.parametrize``; - you can't easily undo the mocking during the test execution; - - **Note about usage as context manager** - - Although mocker's API is intentionally the same as ``mock.patch``'s, its use - as context manager and function decorator is **not** supported through the - fixture. The purpose of this plugin is to make the use of context managers and - function decorators for mocking unnecessary. Indeed, trying to use the - functionality in ``mocker`` in this manner can lead to non-intuitive errors: + An alternative is to use ``contextlib.ExitStack`` to stack the context managers in a single level of indentation + to improve the flow of the test: .. code-block:: python - def test_context_manager(mocker): - a = A() - with mocker.patch.object(a, 'doIt', return_value=True, autospec=True): - assert a.doIt() == True - - .. code-block:: console + import contextlib + import mock - ================================== FAILURES =================================== - ____________________________ test_context_manager _____________________________ - in test_context_manager - with mocker.patch.object(a, 'doIt', return_value=True, autospec=True): - E AttributeError: __exit__ - - You can however use ``mocker.mock_module`` to access the underlying ``mock`` - module, e.g. to return a context manager in a fixture that mocks something - temporarily: + def test_unix_fs(): + with contextlib.ExitStack() as stack: + stack.enter_context(mock.patch('os.remove')) + UnixFS.rm('file') + os.remove.assert_called_once_with('file') - .. code-block:: python + stack.enter_context(mock.patch('os.listdir')) + assert UnixFS.ls('dir') == expected + # ... - @pytest.fixture - def fixture_cm(mocker): - @contextlib.contextmanager - def my_cm(): - def mocked(): - pass - - with mocker.mock_module.patch.object(SomeClass, 'method', mocked): - yield - return my_cm + stack.enter_context(mock.patch('shutil.copy')) + UnixFS.cp('src', 'dst') + # ... + But this is arguably a little more complex than using ``pytest-mock``. Contributing ============ @@ -352,6 +350,11 @@ Distributed under the terms of the `MIT`_ license. + Security contact information + ============================ + + To report a security vulnerability, please use the `Tidelift security contact <https://tidelift.com/security>`__. Tidelift will coordinate the fix and disclosure. + .. _MIT: https://github.com/pytest-dev/pytest-mock/blob/master/LICENSE Keywords: pytest mock diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/README.rst new/pytest-mock-1.11.0/README.rst --- old/pytest-mock-1.10.4/README.rst 2019-04-17 19:23:43.000000000 +0200 +++ new/pytest-mock-1.11.0/README.rst 2019-09-28 20:53:36.000000000 +0200 @@ -24,7 +24,7 @@ -|python| |version| |anaconda| |ci| |appveyor| |coverage| |black| +|python| |version| |anaconda| |ci| |coverage| |black| .. |version| image:: http://img.shields.io/pypi/v/pytest-mock.svg :target: https://pypi.python.org/pypi/pytest-mock @@ -32,11 +32,8 @@ .. |anaconda| image:: https://img.shields.io/conda/vn/conda-forge/pytest-mock.svg :target: https://anaconda.org/conda-forge/pytest-mock -.. |ci| image:: http://img.shields.io/travis/pytest-dev/pytest-mock.svg - :target: https://travis-ci.org/pytest-dev/pytest-mock - -.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/pid1t7iuwhkm9eh6/branch/master?svg=true - :target: https://ci.appveyor.com/project/pytestbot/pytest-mock +.. |ci| image:: https://github.com/pytest-dev/pytest-mock/workflows/build/badge.svg + :target: https://github.com/pytest-dev/pytest-mock/actions .. |coverage| image:: http://img.shields.io/coveralls/pytest-dev/pytest-mock.svg :target: https://coveralls.io/r/pytest-dev/pytest-mock @@ -88,10 +85,9 @@ Spy --- -The spy acts exactly like the original method in all cases, except it allows use of `mock` +The spy acts exactly like the original method in all cases, except it allows use of ``mock`` features with it, like retrieving call count. It also works for class and static methods. - .. code-block:: python def test_spy(mocker): @@ -104,6 +100,9 @@ assert foo.bar() == 42 assert foo.bar.call_count == 1 +Since version ``1.11``, it is also possible to query the ``return_value`` attribute +to observe what the spied function/method returned. + Stub ---- @@ -198,6 +197,23 @@ Python 3.4+. Note that this option is only used in Python 3+, as Python 2 users only have the option to use the ``mock`` package from PyPI anyway. +Note about usage as context manager +----------------------------------- + +Although mocker's API is intentionally the same as ``mock.patch``'s, its use +as context manager and function decorator is **not** supported through the +fixture: + +.. code-block:: python + + def test_context_manager(mocker): + a = A() + with mocker.patch.object(a, 'doIt', return_value=True, autospec=True): # DO NOT DO THIS + assert a.doIt() == True + +The purpose of this plugin is to make the use of context managers and +function decorators for mocking unnecessary. + Requirements ============ @@ -277,47 +293,29 @@ naming fixtures as parameters, or ``pytest.mark.parametrize``; - you can't easily undo the mocking during the test execution; - -**Note about usage as context manager** - -Although mocker's API is intentionally the same as ``mock.patch``'s, its use -as context manager and function decorator is **not** supported through the -fixture. The purpose of this plugin is to make the use of context managers and -function decorators for mocking unnecessary. Indeed, trying to use the -functionality in ``mocker`` in this manner can lead to non-intuitive errors: +An alternative is to use ``contextlib.ExitStack`` to stack the context managers in a single level of indentation +to improve the flow of the test: .. code-block:: python - def test_context_manager(mocker): - a = A() - with mocker.patch.object(a, 'doIt', return_value=True, autospec=True): - assert a.doIt() == True - -.. code-block:: console + import contextlib + import mock - ================================== FAILURES =================================== - ____________________________ test_context_manager _____________________________ - in test_context_manager - with mocker.patch.object(a, 'doIt', return_value=True, autospec=True): - E AttributeError: __exit__ - -You can however use ``mocker.mock_module`` to access the underlying ``mock`` -module, e.g. to return a context manager in a fixture that mocks something -temporarily: + def test_unix_fs(): + with contextlib.ExitStack() as stack: + stack.enter_context(mock.patch('os.remove')) + UnixFS.rm('file') + os.remove.assert_called_once_with('file') -.. code-block:: python + stack.enter_context(mock.patch('os.listdir')) + assert UnixFS.ls('dir') == expected + # ... - @pytest.fixture - def fixture_cm(mocker): - @contextlib.contextmanager - def my_cm(): - def mocked(): - pass - - with mocker.mock_module.patch.object(SomeClass, 'method', mocked): - yield - return my_cm + stack.enter_context(mock.patch('shutil.copy')) + UnixFS.cp('src', 'dst') + # ... +But this is arguably a little more complex than using ``pytest-mock``. Contributing ============ @@ -344,4 +342,9 @@ Distributed under the terms of the `MIT`_ license. +Security contact information +============================ + +To report a security vulnerability, please use the `Tidelift security contact <https://tidelift.com/security>`__. Tidelift will coordinate the fix and disclosure. + .. _MIT: https://github.com/pytest-dev/pytest-mock/blob/master/LICENSE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/_pytest_mock_version.py new/pytest-mock-1.11.0/_pytest_mock_version.py --- old/pytest-mock-1.10.4/_pytest_mock_version.py 2019-04-17 19:23:59.000000000 +0200 +++ new/pytest-mock-1.11.0/_pytest_mock_version.py 2019-09-28 20:53:45.000000000 +0200 @@ -1,4 +1,4 @@ # coding: utf-8 # file generated by setuptools_scm # don't change, don't track in version control -version = '1.10.4' +version = '1.11.0' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/appveyor.yml new/pytest-mock-1.11.0/appveyor.yml --- old/pytest-mock-1.10.4/appveyor.yml 2019-04-17 19:23:43.000000000 +0200 +++ new/pytest-mock-1.11.0/appveyor.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,10 +0,0 @@ -install: - - C:\Python37\python -m pip install -U pip - - C:\Python37\python -m pip install tox - -build: false # Not a C# project - -test_script: - - C:\Python37\scripts\tox - -skip_tags: true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/pytest_mock.egg-info/PKG-INFO new/pytest-mock-1.11.0/pytest_mock.egg-info/PKG-INFO --- old/pytest-mock-1.10.4/pytest_mock.egg-info/PKG-INFO 2019-04-17 19:23:59.000000000 +0200 +++ new/pytest-mock-1.11.0/pytest_mock.egg-info/PKG-INFO 2019-09-28 20:53:45.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pytest-mock -Version: 1.10.4 +Version: 1.11.0 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 @@ -32,7 +32,7 @@ - |python| |version| |anaconda| |ci| |appveyor| |coverage| |black| + |python| |version| |anaconda| |ci| |coverage| |black| .. |version| image:: http://img.shields.io/pypi/v/pytest-mock.svg :target: https://pypi.python.org/pypi/pytest-mock @@ -40,11 +40,8 @@ .. |anaconda| image:: https://img.shields.io/conda/vn/conda-forge/pytest-mock.svg :target: https://anaconda.org/conda-forge/pytest-mock - .. |ci| image:: http://img.shields.io/travis/pytest-dev/pytest-mock.svg - :target: https://travis-ci.org/pytest-dev/pytest-mock - - .. |appveyor| image:: https://ci.appveyor.com/api/projects/status/pid1t7iuwhkm9eh6/branch/master?svg=true - :target: https://ci.appveyor.com/project/pytestbot/pytest-mock + .. |ci| image:: https://github.com/pytest-dev/pytest-mock/workflows/build/badge.svg + :target: https://github.com/pytest-dev/pytest-mock/actions .. |coverage| image:: http://img.shields.io/coveralls/pytest-dev/pytest-mock.svg :target: https://coveralls.io/r/pytest-dev/pytest-mock @@ -96,10 +93,9 @@ Spy --- - The spy acts exactly like the original method in all cases, except it allows use of `mock` + The spy acts exactly like the original method in all cases, except it allows use of ``mock`` features with it, like retrieving call count. It also works for class and static methods. - .. code-block:: python def test_spy(mocker): @@ -112,6 +108,9 @@ assert foo.bar() == 42 assert foo.bar.call_count == 1 + Since version ``1.11``, it is also possible to query the ``return_value`` attribute + to observe what the spied function/method returned. + Stub ---- @@ -206,6 +205,23 @@ Python 3.4+. Note that this option is only used in Python 3+, as Python 2 users only have the option to use the ``mock`` package from PyPI anyway. + Note about usage as context manager + ----------------------------------- + + Although mocker's API is intentionally the same as ``mock.patch``'s, its use + as context manager and function decorator is **not** supported through the + fixture: + + .. code-block:: python + + def test_context_manager(mocker): + a = A() + with mocker.patch.object(a, 'doIt', return_value=True, autospec=True): # DO NOT DO THIS + assert a.doIt() == True + + The purpose of this plugin is to make the use of context managers and + function decorators for mocking unnecessary. + Requirements ============ @@ -285,47 +301,29 @@ naming fixtures as parameters, or ``pytest.mark.parametrize``; - you can't easily undo the mocking during the test execution; - - **Note about usage as context manager** - - Although mocker's API is intentionally the same as ``mock.patch``'s, its use - as context manager and function decorator is **not** supported through the - fixture. The purpose of this plugin is to make the use of context managers and - function decorators for mocking unnecessary. Indeed, trying to use the - functionality in ``mocker`` in this manner can lead to non-intuitive errors: + An alternative is to use ``contextlib.ExitStack`` to stack the context managers in a single level of indentation + to improve the flow of the test: .. code-block:: python - def test_context_manager(mocker): - a = A() - with mocker.patch.object(a, 'doIt', return_value=True, autospec=True): - assert a.doIt() == True - - .. code-block:: console + import contextlib + import mock - ================================== FAILURES =================================== - ____________________________ test_context_manager _____________________________ - in test_context_manager - with mocker.patch.object(a, 'doIt', return_value=True, autospec=True): - E AttributeError: __exit__ - - You can however use ``mocker.mock_module`` to access the underlying ``mock`` - module, e.g. to return a context manager in a fixture that mocks something - temporarily: + def test_unix_fs(): + with contextlib.ExitStack() as stack: + stack.enter_context(mock.patch('os.remove')) + UnixFS.rm('file') + os.remove.assert_called_once_with('file') - .. code-block:: python + stack.enter_context(mock.patch('os.listdir')) + assert UnixFS.ls('dir') == expected + # ... - @pytest.fixture - def fixture_cm(mocker): - @contextlib.contextmanager - def my_cm(): - def mocked(): - pass - - with mocker.mock_module.patch.object(SomeClass, 'method', mocked): - yield - return my_cm + stack.enter_context(mock.patch('shutil.copy')) + UnixFS.cp('src', 'dst') + # ... + But this is arguably a little more complex than using ``pytest-mock``. Contributing ============ @@ -352,6 +350,11 @@ Distributed under the terms of the `MIT`_ license. + Security contact information + ============================ + + To report a security vulnerability, please use the `Tidelift security contact <https://tidelift.com/security>`__. Tidelift will coordinate the fix and disclosure. + .. _MIT: https://github.com/pytest-dev/pytest-mock/blob/master/LICENSE Keywords: pytest mock diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/pytest_mock.egg-info/SOURCES.txt new/pytest-mock-1.11.0/pytest_mock.egg-info/SOURCES.txt --- old/pytest-mock-1.10.4/pytest_mock.egg-info/SOURCES.txt 2019-04-17 19:23:59.000000000 +0200 +++ new/pytest-mock-1.11.0/pytest_mock.egg-info/SOURCES.txt 2019-09-28 20:53:46.000000000 +0200 @@ -1,17 +1,17 @@ .gitignore .pre-commit-config.yaml -.travis.yml CHANGELOG.rst HOWTORELEASE.rst LICENSE README.rst _pytest_mock_version.py -appveyor.yml pytest_mock.py setup.cfg setup.py test_pytest_mock.py tox.ini +.github/FUNDING.yml +.github/workflows/main.yml pytest_mock.egg-info/PKG-INFO pytest_mock.egg-info/SOURCES.txt pytest_mock.egg-info/dependency_links.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/pytest_mock.py new/pytest-mock-1.11.0/pytest_mock.py --- old/pytest-mock-1.10.4/pytest_mock.py 2019-04-17 19:23:43.000000000 +0200 +++ new/pytest-mock-1.11.0/pytest_mock.py 2019-09-28 20:53:36.000000000 +0200 @@ -2,6 +2,7 @@ import inspect import sys +from functools import wraps import pytest @@ -104,7 +105,13 @@ if isinstance(value, (classmethod, staticmethod)): autospec = False - result = self.patch.object(obj, name, side_effect=method, autospec=autospec) + @wraps(method) + def wrapper(*args, **kwargs): + r = method(*args, **kwargs) + result.return_value = r + return r + + result = self.patch.object(obj, name, side_effect=wrapper, autospec=autospec) return result def stub(self, name=None): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/test_pytest_mock.py new/pytest-mock-1.11.0/test_pytest_mock.py --- old/pytest-mock-1.10.4/test_pytest_mock.py 2019-04-17 19:23:43.000000000 +0200 +++ new/pytest-mock-1.11.0/test_pytest_mock.py 2019-09-28 20:53:36.000000000 +0200 @@ -10,11 +10,11 @@ # could not make some of the tests work on PyPy, patches are welcome! skip_pypy = pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="could not make work on pypy" + platform.python_implementation() == "PyPy", reason="could not make it work on pypy" ) -# Python 3.8 changed the output formatting (bpo-35500). -PY38 = sys.version_info >= (3, 8) +# Python 3.8 changed the output formatting (bpo-35500), which has been ported to mock 3.0 +NEW_FORMATTING = sys.version_info >= (3, 8) or sys.version_info[0] == 2 @pytest.fixture @@ -209,7 +209,7 @@ def __test_failure_message(self, mocker, **kwargs): expected_name = kwargs.get("name") or "mock" - if PY38: + if NEW_FORMATTING: msg = "expected call not found.\nExpected: {0}()\nActual: not called." else: msg = "Expected call: {0}()\nNot called" @@ -238,7 +238,9 @@ assert foo.bar(arg=10) == 20 assert other.bar(arg=10) == 20 foo.bar.assert_called_once_with(arg=10) + assert foo.bar.return_value == 20 spy.assert_called_once_with(arg=10) + assert spy.return_value == 20 @skip_pypy @@ -272,6 +274,7 @@ assert other.bar(arg=10) == 20 calls = [mocker.call(foo, arg=10), mocker.call(other, arg=10)] assert spy.call_args_list == calls + assert spy.return_value == 20 @skip_pypy @@ -284,7 +287,9 @@ spy = mocker.spy(Foo, "bar") assert Foo.bar(arg=10) == 20 Foo.bar.assert_called_once_with(arg=10) + assert Foo.bar.return_value == 20 spy.assert_called_once_with(arg=10) + assert spy.return_value == 20 @skip_pypy @@ -301,7 +306,9 @@ spy = mocker.spy(Foo, "bar") assert Foo.bar(arg=10) == 20 Foo.bar.assert_called_once_with(arg=10) + assert Foo.bar.return_value == 20 spy.assert_called_once_with(arg=10) + assert spy.return_value == 20 @skip_pypy @@ -320,7 +327,9 @@ spy = mocker.spy(Foo, "bar") assert Foo.bar(arg=10) == 20 Foo.bar.assert_called_once_with(arg=10) + assert Foo.bar.return_value == 20 spy.assert_called_once_with(arg=10) + assert spy.return_value == 20 @skip_pypy @@ -333,7 +342,9 @@ spy = mocker.spy(Foo, "bar") assert Foo.bar(arg=10) == 20 Foo.bar.assert_called_once_with(arg=10) + assert Foo.bar.return_value == 20 spy.assert_called_once_with(arg=10) + assert spy.return_value == 20 @skip_pypy @@ -350,7 +361,9 @@ spy = mocker.spy(Foo, "bar") assert Foo.bar(arg=10) == 20 Foo.bar.assert_called_once_with(arg=10) + assert Foo.bar.return_value == 20 spy.assert_called_once_with(arg=10) + assert spy.return_value == 20 @contextmanager @@ -620,7 +633,7 @@ """ ) result = testdir.runpytest("-s") - if PY38: + if NEW_FORMATTING: expected_lines = [ "*AssertionError: expected call not found.", "*Expected: mock('', bar=4)", @@ -639,7 +652,7 @@ "*Use -v to get the full diff*", "*Kwargs:*", "*assert {} == {'bar': 4}*", - "*Right contains more items:*", + "*Right contains* more item*", "*{'bar': 4}*", "*Use -v to get the full diff*", ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-mock-1.10.4/tox.ini new/pytest-mock-1.11.0/tox.ini --- old/pytest-mock-1.10.4/tox.ini 2019-04-17 19:23:43.000000000 +0200 +++ new/pytest-mock-1.11.0/tox.ini 2019-09-28 20:53:36.000000000 +0200 @@ -10,7 +10,7 @@ [testenv:norewrite] commands = - pytest test_pytest_mock.py --assert=plain -ra + pytest test_pytest_mock.py --assert=plain [testenv:linting] skipsdist = True @@ -20,7 +20,7 @@ commands = pre-commit run --all-files --show-diff-on-failure [pytest] -addopts = -ra +addopts = -r a [flake8] max-line-length = 88
