Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b957883
Use latest orb version
cjw296 Mar 1, 2025
c702930
Test against Python 3.13
cjw296 Mar 1, 2025
9942de9
Add new required Read The Docs key
cjw296 Mar 1, 2025
cc3ca4c
gh-61215: threadingmock: Improve test suite to avoid race conditions …
mariocj89 Jul 17, 2023
342f253
Update Lib/test/test_unittest/testmock/testmock.py: fix typo RuntimEr…
falconlee236 Sep 3, 2023
33a6d72
gh-109653: Remove unused imports in the `Lib/` directory (#109803)
AlexWaygood Sep 24, 2023
236785f
gh-111019: Align expected and actual titles in test output (#111020)
morisja Oct 18, 2023
c9fda31
gh-113407: Fix import of unittest.mock when CPython is built without …
serhiy-storchaka Dec 24, 2023
88cf9ef
gh-113569: Display calls in Mock.assert_has_calls failure when empty …
wookie184 Jan 4, 2024
86235ef
Python 3.6 error message assertion
cjw296 Mar 1, 2025
531064f
gh-115274: Fix direct invocation of `testmock/testpatch.py` (#115275)
sobolevn Feb 11, 2024
d6bc819
gh-75988: Fix issues with autospec ignoring wrapped object (#115223)
infohash Mar 8, 2024
6e3aca1
gh-117860: Add tests for resolving names when import rebind names (GH…
serhiy-storchaka Apr 30, 2024
e5fd961
Revert "gh-117860: Add tests for resolving names when import rebind n…
cjw296 Mar 1, 2025
d8fad17
gh-90848: Fixed create_autospec ignoring configure_mock style kwargs …
infohash May 2, 2024
b994ccb
Remove almost all unpaired backticks in docstrings (#119231)
geofft May 22, 2024
091f8d5
gh-119600: mock: do not access attributes of original when new_callab…
rbtcollins Jun 11, 2024
f31ce73
gh-65454: avoid triggering call to a PropertyMock in NonCallableMock.…
blhsing Jun 11, 2024
d1b6956
gh-120732: Fix `name` passing to `Mock`, when using kwargs to `create…
sobolevn Jun 19, 2024
0243cb6
gh-117765: Improve documentation for `mocker.patch.dict` (#121755)
GovernmentPlates Jul 15, 2024
74d0fcc
ensure we always use iscoroutinefunction from backports in non-test code
cjw296 Mar 3, 2025
7abb784
Use iscoroutinefunction and IsolatedAsyncioTestCase when importable
cjw296 Mar 3, 2025
c0920f3
gh-122858: Deprecate `asyncio.iscoroutinefunction` (#122875)
Wulian233 Aug 11, 2024
5ae648f
Adjust source of iscoroutinefunction is backports
cjw296 Mar 3, 2025
ce4de2c
Backports: e6d5ff55d0816d7f5eb45e49c810e936b09d2be7, skipped: We have…
cjw296 Mar 3, 2025
2982e18
Remove unused variable in `MagicMixin._mock_set_magics` (#124092)
sobolevn Sep 14, 2024
82afa5f
gh-123934: Fix `MagicMock` not to reset magic method return values (#…
sobolevn Sep 19, 2024
e4aa029
gh-124234: Improve docs for `Mock.reset_mock` (#124237)
sobolevn Sep 26, 2024
dd8d0c2
gh-124176: Add special support for dataclasses to `create_autospec` (…
sobolevn Sep 27, 2024
22d17c3
gh-104745: Limit starting a patcher more than once without stopping i…
Red4Ru Nov 13, 2024
8ac6d62
gh-127949: deprecate `asyncio.set_event_loop_policy` (#128024)
kumaraditya303 Dec 18, 2024
7cf5bc4
gh-71339: Add additional assertion methods for unittest (GH-128707)
serhiy-storchaka Jan 14, 2025
5f2a772
Revert "gh-71339: Add additional assertion methods for unittest (GH-1…
cjw296 Mar 3, 2025
f3afe3b
Add set_event_loop_policy to backports
cjw296 Mar 3, 2025
13edc92
Fix bug in backporting docs
cjw296 Mar 3, 2025
012c5ac
Backport-specific code coverage fixes
cjw296 Mar 3, 2025
b4356fb
`unittest.mock` test and coverage fixup (#130787)
cjw296 Mar 3, 2025
3a9e809
latest sync point
cjw296 Mar 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
python: cjw296/python-ci@4
python: cjw296/python-ci@5

jobs:
check-package:
Expand Down Expand Up @@ -37,6 +37,7 @@ common: &common
- cimg/python:3.10
- cimg/python:3.11
- cimg/python:3.12
- cimg/python:3.13

- python/pip-run-tests:
python: pypy3
Expand Down Expand Up @@ -71,7 +72,7 @@ common: &common
parameters:
image:
- cimg/python:3.6
- cimg/python:3.12
- cimg/python:3.13
requires:
- package

Expand Down
1 change: 1 addition & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ python:
- docs
sphinx:
fail_on_warning: true
configuration: docs/conf.py
1 change: 1 addition & 0 deletions NEWS.d/2023-12-22-20-49-52.gh-issue-113407.C_O13_.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix import of :mod:`unittest.mock` when CPython is built without docstrings.
2 changes: 2 additions & 0 deletions NEWS.d/2023-12-29-17-57-45.gh-issue-113569.qcRCEI.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Indicate if there were no actual calls in unittest
:meth:`~unittest.mock.Mock.assert_has_calls` failure.
1 change: 1 addition & 0 deletions NEWS.d/2024-02-27-13-05-51.gh-issue-75988.In6LlB.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed :func:`unittest.mock.create_autospec` to pass the call through to the wrapped object to return the real result.
1 change: 1 addition & 0 deletions NEWS.d/2024-04-22-21-54-12.gh-issue-90848.5jHEEc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed :func:`unittest.mock.create_autospec` to configure parent mock with keyword arguments.
1 change: 1 addition & 0 deletions NEWS.d/2024-06-04-08-57-02.gh-issue-65454.o9j4wF.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:func:`unittest.mock.Mock.attach_mock` no longer triggers a call to a ``PropertyMock`` being attached.
2 changes: 2 additions & 0 deletions NEWS.d/2024-06-10-14-00-40.gh-issue-119600.jJMf4C.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :func:`unittest.mock.patch` to not read attributes of the target when
``new_callable`` is set. Patch by Robert Collins.
2 changes: 2 additions & 0 deletions NEWS.d/2024-06-19-15-06-58.gh-issue-120732.OvYV9b.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix ``name`` passing to :class:`unittest.mock.Mock` object when using
:func:`unittest.mock.create_autospec`.
1 change: 1 addition & 0 deletions NEWS.d/2024-07-14-12-25-53.gh-issue-117765.YFMOUv.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved documentation for :func:`unittest.mock.patch.dict`
2 changes: 2 additions & 0 deletions NEWS.d/2024-08-10-10-21-44.gh-issue-122858.ZC1rJD.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deprecate :func:`!asyncio.iscoroutinefunction` in favor of
:func:`inspect.iscoroutinefunction`.
2 changes: 2 additions & 0 deletions NEWS.d/2024-09-13-10-34-19.gh-issue-123934.yMe7mL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :class:`unittest.mock.MagicMock` reseting magic methods return values
after ``.reset_mock(return_value=True)`` was called.
4 changes: 4 additions & 0 deletions NEWS.d/2024-09-24-13-32-16.gh-issue-124176.6hmOPz.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add support for :func:`dataclasses.dataclass` in
:func:`unittest.mock.create_autospec`. Now ``create_autospec`` will check
for potential dataclasses and use :func:`dataclasses.fields` function to
retrieve the spec information.
3 changes: 3 additions & 0 deletions NEWS.d/2024-11-10-18-14-51.gh-issue-104745.zAa5Ke.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Limit starting a patcher (from :func:`unittest.mock.patch` or
:func:`unittest.mock.patch.object`) more than
once without stopping it
2 changes: 1 addition & 1 deletion docs/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Backporting rules
.. code-block:: python

def will_never_be_called():
pass # pragma: no cov
pass # pragma: no cover

- If code such as this causes coverage checking to drop below 100%:

Expand Down
2 changes: 1 addition & 1 deletion lastsync.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e6379f72cbc60f6b3c5676f9e225d4f145d5693f
04091c083340dde7d4eeb6d945c70f3b37d88f85
25 changes: 17 additions & 8 deletions mock/backports.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import sys


if sys.version_info[:2] < (3, 8):
if sys.version_info[:2] > (3, 9):
from inspect import iscoroutinefunction
elif sys.version_info[:2] >= (3, 8):
from asyncio import iscoroutinefunction
else:

import asyncio, functools
import functools
from asyncio.coroutines import _is_coroutine
from inspect import ismethod, isfunction, CO_COROUTINE
from unittest import TestCase

def _unwrap_partial(func):
while isinstance(func, functools.partial):
Expand Down Expand Up @@ -35,6 +38,13 @@ def iscoroutinefunction(obj):
)


try:
from unittest import IsolatedAsyncioTestCase
except ImportError:
import asyncio
from unittest import TestCase


class IsolatedAsyncioTestCase(TestCase):

def __init__(self, methodName='runTest'):
Expand Down Expand Up @@ -82,8 +92,7 @@ def run(self, result=None):
self._tearDownAsyncioLoop()


else:

from asyncio import iscoroutinefunction
from unittest import IsolatedAsyncioTestCase

try:
from asyncio import _set_event_loop_policy as set_event_loop_policy
except ImportError:
from asyncio import set_event_loop_policy
Loading