diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..be006de --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# Keep GitHub Actions up to date with GitHub's Dependabot... +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + groups: + github-actions: + patterns: + - "*" # Group all Actions updates into a single larger pull request + schedule: + interval: weekly diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 39d0512..6b97052 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,14 +12,21 @@ jobs: package: runs-on: ubuntu-latest + # Required by attest-build-provenance-github. + permissions: + id-token: write + attestations: write env: SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v1.5 + uses: hynek/build-and-inspect-python-package@v2.12.0 + with: + attest-build-provenance-github: 'true' + deploy: needs: package @@ -30,16 +37,18 @@ jobs: contents: write # For tag and release notes. steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Download Package - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Packages path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.5 + uses: pypa/gh-action-pypi-publish@v1.12.4 + with: + attestations: true - name: Push tag run: | @@ -49,7 +58,7 @@ jobs: git push origin v${{ github.event.inputs.version }} - name: Set up Python - uses: actions/setup-python@v4.5.0 + uses: actions/setup-python@v5 with: python-version: "3.10" @@ -60,7 +69,7 @@ jobs: python scripts/gen-release-notes.py - name: GitHub Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: body_path: scripts/latest-release-notes.md files: dist/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7bc8f62..6443b3b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,10 +17,16 @@ jobs: package: runs-on: ubuntu-latest + permissions: + id-token: write + attestations: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v1.5 + uses: hynek/build-and-inspect-python-package@v2.12.0 + with: + # Disabling because this is failing currently, see #466. + attest-build-provenance-github: 'false' test: @@ -31,7 +37,7 @@ jobs: strategy: fail-fast: false matrix: - python: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"] os: [ubuntu-latest, windows-latest] tox_env: ["py"] include: @@ -46,16 +52,16 @@ jobs: tox_env: "norewrite" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Download Package - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Packages path: dist - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b4c9dd..da96096 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,13 +9,13 @@ repos: language: python additional_dependencies: [pygments, restructuredtext_lint] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.3 + rev: v0.11.10 hooks: - id: ruff args: ["--fix"] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.9.0 + rev: v1.15.0 hooks: - id: mypy files: ^(src|tests) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 005dd03..a826133 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ Releases ======== +3.14.1 (2025-08-26) +------------------- + +* `#503 `_: Python 3.14 is now officially supported. + 3.14.0 (2024-03-21) ------------------- diff --git a/docs/usage.rst b/docs/usage.rst index c576dd0..339746a 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -29,6 +29,7 @@ Also, as a convenience, these names from the ``mock`` module are accessible dire * `Mock `_ * `MagicMock `_ * `PropertyMock `_ +* `AsyncMock `_ * `ANY `_ * `DEFAULT `_ * `call `_ diff --git a/pyproject.toml b/pyproject.toml index 9865b37..f73f8ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,8 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Topic :: Software Development :: Testing", ] diff --git a/src/pytest_mock/plugin.py b/src/pytest_mock/plugin.py index 1e0a0b2..50dc06a 100644 --- a/src/pytest_mock/plugin.py +++ b/src/pytest_mock/plugin.py @@ -1,4 +1,3 @@ -import asyncio import builtins import functools import inspect @@ -196,7 +195,7 @@ async def async_wrapper(*args, **kwargs): spy_obj.spy_return_list.append(r) return r - if asyncio.iscoroutinefunction(method): + if inspect.iscoroutinefunction(method): wrapped = functools.update_wrapper(async_wrapper, method) else: wrapped = functools.update_wrapper(wrapper, method) @@ -265,7 +264,7 @@ def _start_patch( "Mocks returned by pytest-mock do not need to be used as context managers. " "The mocker fixture automatically undoes mocking at the end of a test. " "This warning can be ignored if it was triggered by mocking a context manager. " - "https://pytest-mock.readthedocs.io/en/latest/remarks.html#usage-as-context-manager", + "https://pytest-mock.readthedocs.io/en/latest/usage.html#usage-as-context-manager", PytestMockWarning, stacklevel=5, ) diff --git a/tests/test_pytest_mock.py b/tests/test_pytest_mock.py index fc16490..1a51636 100644 --- a/tests/test_pytest_mock.py +++ b/tests/test_pytest_mock.py @@ -13,6 +13,7 @@ from unittest.mock import MagicMock import pytest + from pytest_mock import MockerFixture from pytest_mock import PytestMockWarning @@ -996,7 +997,7 @@ def doIt(self): "Mocks returned by pytest-mock do not need to be used as context managers. " "The mocker fixture automatically undoes mocking at the end of a test. " "This warning can be ignored if it was triggered by mocking a context manager. " - "https://pytest-mock.readthedocs.io/en/latest/remarks.html#usage-as-context-manager" + "https://pytest-mock.readthedocs.io/en/latest/usage.html#usage-as-context-manager" ) with pytest.warns( @@ -1013,7 +1014,7 @@ def test_warn_patch_context_manager(mocker: MockerFixture) -> None: "Mocks returned by pytest-mock do not need to be used as context managers. " "The mocker fixture automatically undoes mocking at the end of a test. " "This warning can be ignored if it was triggered by mocking a context manager. " - "https://pytest-mock.readthedocs.io/en/latest/remarks.html#usage-as-context-manager" + "https://pytest-mock.readthedocs.io/en/latest/usage.html#usage-as-context-manager" ) with pytest.warns( diff --git a/tox.ini b/tox.ini index 8082b5a..f1c0e98 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 3.5.3 -envlist = py{38,39,310,311,312}, norewrite, pytest6 +envlist = py{38,39,310,311,312,313,314}, norewrite, pytest6 [testenv] deps =