[New-bugs-announce] [issue25597] unittest.mock does not wrap dict objects correctly

Darragh Bailey report at bugs.python.org
Tue Nov 10 12:02:38 EST 2015

New submission from Darragh Bailey:

Both unittest.mock and the backported release for earlier pythons don't appear to support mocking of dictionary objects.

Specifically I'm expecting that any of the methods used to test for membership, or get items from a mock object wrapping a dictionary should succeed. However it appears that MagicMock doesn't appear to support this.

Attached file shows an attempt to use different methods with a wrapped dictionary object where only the '.get()' method appears to work as expected.

files: test-mock-wraps-dict.py
messages: 254453
nosy: Darragh Bailey
priority: normal
severity: normal
status: open
title: unittest.mock does not wrap dict objects correctly
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file41001/test-mock-wraps-dict.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list