Author xtreak
Recipients Darragh Bailey, anthonypjshaw, cjw296, josephgordon, mariocj89, michael.foord, r.david.murray, rbcollins, xtreak
Date 2019-09-09.14:03:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568037812.85.0.526808278585.issue25597@roundup.psfhosted.org>
In-reply-to
Content
This seems to a reasonable change to me since dict.get returns the value then making a contains check dict.__contains__ should return True instead of the fixed return value of False. Below is a patch where the mock_wraps attribute is set with the relevant method that would make sure in the report dict.get would used.


diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 298b41e0d7..077d22d08e 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1935,6 +1935,12 @@ _side_effect_methods = {


 def _set_return_value(mock, method, name):
+    # If _mock_wraps is present then attach it so that it's 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
History
Date User Action Args
2019-09-09 14:03:32xtreaksetrecipients: + xtreak, rbcollins, cjw296, r.david.murray, michael.foord, josephgordon, Darragh Bailey, anthonypjshaw, mariocj89
2019-09-09 14:03:32xtreaksetmessageid: <1568037812.85.0.526808278585.issue25597@roundup.psfhosted.org>
2019-09-09 14:03:32xtreaklinkissue25597 messages
2019-09-09 14:03:32xtreakcreate