Issue 32299: unittest.mock.patch.dict.enter should return the dict (original) (raw)

Issue32299

Created on 2017-12-13 07:08 by Allen Li, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4834 closed Vadim Tsander,2017-12-13 09:59
PR 11062 merged mariocj89,2018-12-10 09:18
Messages (4)
msg308188 - (view) Author: Allen Li (Allen Li) Date: 2017-12-13 07:08
mock.patch.dict.__enter__ should return the patched dict/mapping object. Currently it returns nothing (None). This would make setting up fixtures more convenient: with mock.patch.dict(some.thing): some.thing['foo'] = 'bar' with mock.patch.dict(some.thing) as x: x['foo'] = 'bar'
msg310489 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2018-01-23 09:35
This seems like a reasonable feature request.
msg343772 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-05-28 12:53
New changeset 04530812e90e45a37ed84e83505d63db7edc1262 by Cheryl Sabella (Mario Corchero) in branch 'master': bpo-32299: Return patched dict when using patch.dict as a context manager (GH-11062) https://github.com/python/cpython/commit/04530812e90e45a37ed84e83505d63db7edc1262
msg343775 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-05-28 12:59
@Allen Li, thank you for the report. And thank you, @Vadim Tsander for the original pull request and @mariocj89 for reviving this. Also, thank you @eric.araujo for the review and approval. This has been merged!
History
Date User Action Args
2022-04-11 14:58:55 admin set github: 76480
2019-05-28 12:59:19 cheryl.sabella set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2019-05-28 12:53:35 cheryl.sabella set nosy: + cheryl.sabellamessages: +
2019-04-12 23:28:31 cheryl.sabella set nosy: + xtreakversions: + Python 3.8, - Python 3.7
2018-12-10 09🔞19 mariocj89 set pull_requests: + <pull%5Frequest10296>
2018-01-23 09:35:32 michael.foord set messages: +
2018-01-23 08:09:40 berker.peksag set nosy: + rbcollins, michael.foordversions: - Python 3.6, Python 3.8
2017-12-13 09:59:16 Vadim Tsander set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest4726>
2017-12-13 07:08:31 Allen Li set type: enhancement
2017-12-13 07:08:20 Allen Li create