From 34256163137edf2e5b1f524f37417209298cb559 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 24 Apr 2021 18:38:09 -0300 Subject: [PATCH 1/2] Move setup.cfg to mypy.ini Only contains mypy configuration anyway, so this is more explicit. --- setup.cfg => mypy.ini | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename setup.cfg => mypy.ini (100%) diff --git a/setup.cfg b/mypy.ini similarity index 100% rename from setup.cfg rename to mypy.ini From 4716752f3e98242994749658f4acbf2158cdc051 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 24 Apr 2021 18:39:56 -0300 Subject: [PATCH 2/2] Drop Python 3.5 support Also drop linting environment, as we are using pre-commit.ci now. --- .github/workflows/main.yml | 24 ++---------------------- CHANGELOG.rst | 8 +++++++- setup.py | 3 +-- src/pytest_mock/plugin.py | 6 ++++-- tests/test_pytest_mock.py | 4 ++-- 5 files changed, 16 insertions(+), 29 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a30d3dc..3d0c27e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,11 +10,9 @@ jobs: strategy: fail-fast: false matrix: - python: ["3.5", "3.6", "3.7", "3.8", "3.9"] + python: ["3.6", "3.7", "3.8", "3.9"] os: [ubuntu-latest, windows-latest] include: - - python: "3.5" - tox_env: "py35" - python: "3.6" tox_env: "py36" - python: "3.7" @@ -38,31 +36,13 @@ jobs: 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: if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') runs-on: ubuntu-latest - needs: [build, linting] + needs: build steps: - uses: actions/checkout@v1 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index aa3f710..f263d8d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,10 +1,16 @@ -3.5.2 (UNRELEASED) +3.6.0 (2021-04-24) ------------------ +* pytest-mock no longer supports Python 3.5. + * Correct type annotations for ``mocker.patch.object`` to also include the string form. Thanks `@plannigan`_ for the PR (`#235`_). +* ``reset_all`` now supports ``return_value`` and ``side_effect`` keyword arguments. Thanks `@alex-marty`_ for the PR (`#214`_). + +.. _@alex-marty: https://github.com/alex-marty .. _@plannigan: https://github.com/plannigan +.. _#214: https://github.com/pytest-dev/pytest-mock/pull/214 .. _#235: https://github.com/pytest-dev/pytest-mock/pull/235 3.5.1 (2021-01-10) diff --git a/setup.py b/setup.py index aec1cfe..96db74f 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ package_data={ "pytest_mock": ["py.typed"], }, - python_requires=">=3.5", + python_requires=">=3.6", install_requires=["pytest>=5.0"], use_scm_version={"write_to": "src/pytest_mock/_version.py"}, setup_requires=["setuptools_scm"], @@ -31,7 +31,6 @@ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", diff --git a/src/pytest_mock/plugin.py b/src/pytest_mock/plugin.py index b3b97ad..041926e 100644 --- a/src/pytest_mock/plugin.py +++ b/src/pytest_mock/plugin.py @@ -60,10 +60,12 @@ def __init__(self, config: Any) -> None: if hasattr(mock_module, "seal"): self.seal = mock_module.seal - def resetall(self, *, return_value: bool = False, side_effect: bool = False) -> None: + def resetall( + self, *, return_value: bool = False, side_effect: bool = False + ) -> None: """ Call reset_mock() on all patchers started by this fixture. - + :param bool return_value: Reset the return_value of mocks. :param bool side_effect: Reset the side_effect of mocks. """ diff --git a/tests/test_pytest_mock.py b/tests/test_pytest_mock.py index 14e01ec..b3e374e 100644 --- a/tests/test_pytest_mock.py +++ b/tests/test_pytest_mock.py @@ -191,9 +191,9 @@ def test_mocker_resetall(mocker: MockerFixture) -> None: assert not open.called assert listdir.return_value == "foo" assert list(open.side_effect) == ["baz"] - + mocker.resetall(return_value=True, side_effect=True) - + assert isinstance(listdir.return_value, mocker.Mock) assert open.side_effect is None