Issue 33309: Unittest Mock objects do not freeze arguments they are called with
Created on 2018-04-18 15:53 by slacknate, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| mock_issue.py | slacknate, 2018-04-18 15:53 | Reproduces described issue, assertion error raised when it should not be. | ||
| Messages (3) | |||
|---|---|---|---|
| msg315456 - (view) | Author: Nate Duarte (slacknate) * | Date: 2018-04-18 15:53 | |
It is possible to make a call with a Mock object, for example, where a dictionary is passed to the mock and later modified. If a call assertion is then made against the mock using the initial value/contents of the dictionary the assertion will fail. |
|||
| msg319816 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2018-06-17 14:17 | |
Thanks for the issue. I think this is documented here : https://docs.python.org/3/library/unittest.mock-examples.html#coping-with-mutable-arguments Thanks |
|||
| msg326253 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2018-09-24 15:38 | |
Thanks for the details. As part of triaging I am closing this as not a bug since passing mutable arguments to a mock object and modifying it is a documented behavior at https://docs.python.org/3/library/unittest.mock-examples.html#coping-with-mutable-arguments . Feel free to reopen this if needed. Thanks |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:59 | admin | set | github: 77490 |
| 2018-09-24 15:38:28 | xtreak | set | status: open -> closed resolution: not a bug messages: + msg326253 stage: resolved |
| 2018-06-17 14:17:42 | xtreak | set | nosy:
+ xtreak messages: + msg319816 |
| 2018-04-21 03:30:56 | terry.reedy | set | nosy:
+ rbcollins, ezio.melotti, michael.foord |
| 2018-04-18 15:53:04 | slacknate | create | |
