[New-bugs-announce] [issue32299] unittest.mock.patch.dict.__enter__ should return the dict

Allen Li report at bugs.python.org
Wed Dec 13 02:08:20 EST 2017


New submission from Allen Li <vianchielfaura at gmail.com>:

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'

----------
components: Library (Lib)
messages: 308188
nosy: Allen Li
priority: normal
severity: normal
status: open
title: unittest.mock.patch.dict.__enter__ should return the dict
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32299>
_______________________________________


More information about the New-bugs-announce mailing list