Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-mock for openSUSE:Factory checked in at 2021-02-01 13:26:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-mock (Old)
and /work/SRC/openSUSE:Factory/.python-mock.new.28504 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-mock"
Mon Feb 1 13:26:34 2021 rev:27 rq:866397 version:4.0.3
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-mock/python-mock.changes 2020-05-01 11:04:49.618734909 +0200
+++ /work/SRC/openSUSE:Factory/.python-mock.new.28504/python-mock.changes 2021-02-01 13:28:25.910124402 +0100
@@ -1,0 +2,16 @@
+Sun Jan 24 18:10:57 UTC 2021 - Dirk M��ller
+
+- update to 4.0.3:
+ * Issue #42532: Remove unexpected call of ``__bool__`` when passing a
+ ``spec_arg`` argument to a Mock.
+ * Issue #39966: Revert bpo-25597. :class:`unittest.mock.MagicMock` with
+ wraps' set uses default return values for magic methods.
+ * Issue #41877: Mock objects which are not unsafe will now raise an
+ AttributeError if an attribute with the prefix asert, aseert, or assrt is
+ accessed, in addition to this already happening for the prefixes assert or
+ assret.
+ * Issue #40126: Fixed reverting multiple patches in unittest.mock. Patcher's
+ ``__exit__()`` is now never called if its ``__enter__()`` is failed.
+ Returning true from ``__exit__()`` silences now the exception.
+
+-------------------------------------------------------------------
Old:
----
4.0.2.tar.gz
New:
----
4.0.3.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-mock.spec ++++++
--- /var/tmp/diff_new_pack.0dyLwS/_old 2021-02-01 13:28:26.610125491 +0100
+++ /var/tmp/diff_new_pack.0dyLwS/_new 2021-02-01 13:28:26.610125491 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-mock
#
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -27,7 +27,7 @@
%bcond_with test
%endif
Name: python-mock%{psuffix}
-Version: 4.0.2
+Version: 4.0.3
Release: 0
Summary: A Python Mocking and Patching Library for Testing
License: BSD-2-Clause
++++++ 4.0.2.tar.gz -> 4.0.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-4.0.2/.github/ISSUE_TEMPLATE/bug_report.md new/mock-4.0.3/.github/ISSUE_TEMPLATE/bug_report.md
--- old/mock-4.0.2/.github/ISSUE_TEMPLATE/bug_report.md 1970-01-01 01:00:00.000000000 +0100
+++ new/mock-4.0.3/.github/ISSUE_TEMPLATE/bug_report.md 2020-12-10 08:30:27.000000000 +0100
@@ -0,0 +1,30 @@
+---
+name: Bug report
+about: Only report bugs here that are specific to this backport.
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+This package is a rolling backport of [`unittest.mock`](https://github.com/python/cpython/blob/master/Lib/unittest/mock.py).
+As such, any problems you encounter most likely need to be fixed upstream.
+
+Before submitting an issue here, please try and reproduce the problem on the latest release of Python 3, including alphas, and replace any import from `mock` with ones from `unittest.mock`.
+
+If the issue still occurs, then please report upstream through https://bugs.python.org/ as it will need to be fixed there so that it can be backported here and released to you.
+
+If the issue does not occur upstream, please file an issue using the template below as it may be an issue specific to the backport:
+
+**What versions are you using?**
+ - Python: [e.g. 3.7.1]
+ - Mock: [e.g. 4.0.2]
+ - Operating System: [e.g.Linux, macOS, Windows]
+
+**What happened?**
+
+<!--
+A clear and concise description of what the problem is, including full tracebacks and code being executed
+-->
+
+**What were you hoping to happen instead?**
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-4.0.2/CHANGELOG.rst new/mock-4.0.3/CHANGELOG.rst
--- old/mock-4.0.2/CHANGELOG.rst 2020-03-11 18:25:49.000000000 +0100
+++ new/mock-4.0.3/CHANGELOG.rst 2020-12-10 08:30:27.000000000 +0100
@@ -1,3 +1,21 @@
+4.0.3
+-----
+
+- Issue #42532: Remove unexpected call of ``__bool__`` when passing a
+ ``spec_arg`` argument to a Mock.
+
+- Issue #39966: Revert bpo-25597. :class:`unittest.mock.MagicMock` with
+ wraps' set uses default return values for magic methods.
+
+- Issue #41877: Mock objects which are not unsafe will now raise an
+ AttributeError if an attribute with the prefix asert, aseert, or assrt is
+ accessed, in addition to this already happening for the prefixes assert or
+ assret.
+
+- Issue #40126: Fixed reverting multiple patches in unittest.mock. Patcher's
+ ``__exit__()`` is now never called if its ``__enter__()`` is failed.
+ Returning true from ``__exit__()`` silences now the exception.
+
4.0.2
-----
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-4.0.2/lastsync.txt new/mock-4.0.3/lastsync.txt
--- old/mock-4.0.2/lastsync.txt 2020-03-11 18:25:49.000000000 +0100
+++ new/mock-4.0.3/lastsync.txt 2020-12-10 08:30:27.000000000 +0100
@@ -1 +1 @@
-e553f204bf0e39b1d701a364bc71b286acb9433f
+c598a04dd29b89ad072245ddaf738badcfb41ac7
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-4.0.2/mock/__init__.py new/mock-4.0.3/mock/__init__.py
--- old/mock-4.0.2/mock/__init__.py 2020-03-11 18:25:49.000000000 +0100
+++ new/mock-4.0.3/mock/__init__.py 2020-12-10 08:30:27.000000000 +0100
@@ -7,7 +7,7 @@
import mock.mock as _mock
from mock.mock import *
-__version__ = '4.0.2'
+__version__ = '4.0.3'
version_info = tuple(int(p) for p in
re.match(r'(\d+).(\d+).(\d+)', __version__).groups())
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-4.0.2/mock/mock.py new/mock-4.0.3/mock/mock.py
--- old/mock-4.0.2/mock/mock.py 2020-03-11 18:25:49.000000000 +0100
+++ new/mock-4.0.3/mock/mock.py 2020-12-10 08:30:27.000000000 +0100
@@ -408,7 +408,7 @@
# Check if spec is an async object or function
bound_args = _MOCK_SIG.bind_partial(cls, *args, **kw).arguments
spec_arg = bound_args.get('spec_set', bound_args.get('spec'))
- if spec_arg and _is_async_obj(spec_arg):
+ if spec_arg is not None and _is_async_obj(spec_arg):
bases = (AsyncMockMixin, cls)
new = type(cls.__name__, bases, {'__doc__': cls.__doc__})
instance = _safe_super(NonCallableMock, cls).__new__(new)
@@ -633,9 +633,9 @@
elif _is_magic(name):
raise AttributeError(name)
if not self._mock_unsafe:
- if name.startswith(('assert', 'assret')):
+ if name.startswith(('assert', 'assret', 'asert', 'aseert', 'assrt')):
raise AttributeError("Attributes cannot start with 'assert' "
- "or 'assret'")
+ "or its misspellings")
result = self._mock_children.get(name)
if result is _deleted:
@@ -1250,11 +1250,6 @@
return thing
-def _is_started(patcher):
- # XXXX horrible
- return hasattr(patcher, 'is_local')
-
-
class _patch(object):
attribute_name = None
@@ -1325,14 +1320,9 @@
@contextlib.contextmanager
def decoration_helper(self, patched, args, keywargs):
extra_args = []
- entered_patchers = []
- patching = None
-
- exc_info = tuple()
- try:
+ with contextlib.ExitStack() as exit_stack:
for patching in patched.patchings:
- arg = patching.__enter__()
- entered_patchers.append(patching)
+ arg = exit_stack.enter_context(patching)
if patching.attribute_name is not None:
keywargs.update(arg)
elif patching.new is DEFAULT:
@@ -1340,19 +1330,6 @@
args += tuple(extra_args)
yield (args, keywargs)
- except:
- if (patching not in entered_patchers and
- _is_started(patching)):
- # the patcher may have been started, but an exception
- # raised whilst entering one of its additional_patchers
- entered_patchers.append(patching)
- # Pass the exception to __exit__
- exc_info = sys.exc_info()
- # re-raise the exception
- raise
- finally:
- for patching in reversed(entered_patchers):
- patching.__exit__(*exc_info)
def decorate_callable(self, func):
@@ -1529,25 +1506,26 @@
self.temp_original = original
self.is_local = local
- setattr(self.target, self.attribute, new_attr)
- if self.attribute_name is not None:
- extra_args = {}
- if self.new is DEFAULT:
- extra_args[self.attribute_name] = new
- for patching in self.additional_patchers:
- arg = patching.__enter__()
- if patching.new is DEFAULT:
- extra_args.update(arg)
- return extra_args
-
- return new
+ self._exit_stack = contextlib.ExitStack()
+ try:
+ setattr(self.target, self.attribute, new_attr)
+ if self.attribute_name is not None:
+ extra_args = {}
+ if self.new is DEFAULT:
+ extra_args[self.attribute_name] = new
+ for patching in self.additional_patchers:
+ arg = self._exit_stack.enter_context(patching)
+ if patching.new is DEFAULT:
+ extra_args.update(arg)
+ return extra_args
+ return new
+ except:
+ if not self.__exit__(*sys.exc_info()):
+ raise
def __exit__(self, *exc_info):
"""Undo the patch."""
- if not _is_started(self):
- return
-
if self.is_local and self.temp_original is not DEFAULT:
setattr(self.target, self.attribute, self.temp_original)
else:
@@ -1562,9 +1540,9 @@
del self.temp_original
del self.is_local
del self.target
- for patcher in reversed(self.additional_patchers):
- if _is_started(patcher):
- patcher.__exit__(*exc_info)
+ exit_stack = self._exit_stack
+ del self._exit_stack
+ return exit_stack.__exit__(*exc_info)
def start(self):
@@ -1580,9 +1558,9 @@
self._active_patches.remove(self)
except ValueError:
# If the patch hasn't been started this will fail
- pass
+ return None
- return self.__exit__()
+ return self.__exit__(None, None, None)
@@ -1882,9 +1860,9 @@
_patch._active_patches.remove(self)
except ValueError:
# If the patch hasn't been started this will fail
- pass
+ return None
- return self.__exit__()
+ return self.__exit__(None, None, None)
def _clear_dict(in_dict):
@@ -2047,12 +2025,6 @@
def _set_return_value(mock, method, name):
- # If _mock_wraps is present then attach it so that wrapped object
- # is used for return value is used when called.
- if mock._mock_wraps is not None:
- method._mock_wraps = getattr(mock._mock_wraps, name)
- return
-
fixed = _return_values.get(name, DEFAULT)
if fixed is not DEFAULT:
method.return_value = fixed
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-4.0.2/mock/tests/testmock.py new/mock-4.0.3/mock/tests/testmock.py
--- old/mock-4.0.2/mock/tests/testmock.py 2020-03-11 18:25:49.000000000 +0100
+++ new/mock-4.0.3/mock/tests/testmock.py 2020-12-10 08:30:27.000000000 +0100
@@ -716,12 +716,16 @@
def test_magic_method_wraps_dict(self):
+ # bpo-25597: MagicMock with wrap doesn't call wrapped object's
+ # method for magic methods with default values.
data = {'foo': 'bar'}
wrapped_dict = MagicMock(wraps=data)
self.assertEqual(wrapped_dict.get('foo'), 'bar')
- self.assertEqual(wrapped_dict['foo'], 'bar')
- self.assertTrue('foo' in wrapped_dict)
+ # Accessing key gives a MagicMock
+ self.assertIsInstance(wrapped_dict['foo'], MagicMock)
+ # __contains__ method has a default value of False
+ self.assertFalse('foo' in wrapped_dict)
# return_value is non-sentinel and takes precedence over wrapped value.
wrapped_dict.get.return_value = 'return_value'
@@ -732,14 +736,13 @@
self.assertEqual(wrapped_dict.get('foo'), 'bar')
self.assertEqual(wrapped_dict.get('baz'), None)
- with self.assertRaises(KeyError):
- wrapped_dict['baz']
+ self.assertIsInstance(wrapped_dict['baz'], MagicMock)
self.assertFalse('bar' in wrapped_dict)
data['baz'] = 'spam'
self.assertEqual(wrapped_dict.get('baz'), 'spam')
- self.assertEqual(wrapped_dict['baz'], 'spam')
- self.assertTrue('baz' in wrapped_dict)
+ self.assertIsInstance(wrapped_dict['baz'], MagicMock)
+ self.assertFalse('bar' in wrapped_dict)
del data['baz']
self.assertEqual(wrapped_dict.get('baz'), None)
@@ -759,6 +762,7 @@
klass = MagicMock(wraps=Foo)
obj = klass()
self.assertEqual(obj.__getitem__(2), 2)
+ self.assertEqual(obj[2], 2)
self.assertEqual(obj.__custom_method__(), "foo")
@@ -1596,14 +1600,23 @@
#Issue21238
def test_mock_unsafe(self):
m = Mock()
- msg = "Attributes cannot start with 'assert' or 'assret'"
+ msg = "Attributes cannot start with 'assert' or its misspellings"
with self.assertRaisesRegex(AttributeError, msg):
m.assert_foo_call()
with self.assertRaisesRegex(AttributeError, msg):
m.assret_foo_call()
+ with self.assertRaisesRegex(AttributeError, msg):
+ m.asert_foo_call()
+ with self.assertRaisesRegex(AttributeError, msg):
+ m.aseert_foo_call()
+ with self.assertRaisesRegex(AttributeError, msg):
+ m.assrt_foo_call()
m = Mock(unsafe=True)
m.assert_foo_call()
m.assret_foo_call()
+ m.asert_foo_call()
+ m.aseert_foo_call()
+ m.assrt_foo_call()
#Issue21262
def test_assert_not_called(self):
@@ -2154,6 +2167,16 @@
obj = mock(spec=Something)
self.assertIsInstance(obj, Something)
+ def test_bool_not_called_when_passing_spec_arg(self):
+ class Something:
+ def __init__(self):
+ self.obj_with_bool_func = unittest.mock.MagicMock()
+
+ obj = Something()
+ with unittest.mock.patch.object(obj, 'obj_with_bool_func', autospec=True): pass
+
+ self.assertEqual(obj.obj_with_bool_func.__bool__.call_count, 0)
+
if __name__ == '__main__':
unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-4.0.2/mock/tests/testpatch.py new/mock-4.0.3/mock/tests/testpatch.py
--- old/mock-4.0.2/mock/tests/testpatch.py 2020-03-11 18:25:49.000000000 +0100
+++ new/mock-4.0.3/mock/tests/testpatch.py 2020-12-10 08:30:27.000000000 +0100
@@ -774,7 +774,7 @@
d = {'foo': 'bar'}
original = d.copy()
patcher = patch.dict(d, [('spam', 'eggs')], clear=True)
- self.assertEqual(patcher.stop(), False)
+ self.assertFalse(patcher.stop())
self.assertEqual(d, original)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-4.0.2/setup.cfg new/mock-4.0.3/setup.cfg
--- old/mock-4.0.2/setup.cfg 2020-03-11 18:25:49.000000000 +0100
+++ new/mock-4.0.3/setup.cfg 2020-12-10 08:30:27.000000000 +0100
@@ -31,7 +31,7 @@
docs =
sphinx
test =
- pytest
+ pytest<5.4
pytest-cov
build =
twine