python - mock dictionary at module level -
i seek mock dictionary @ module level:
with mock.patch('mymodule.mydict', new_callable=mock.propertymock) mock_dict: mock_dict.return_value={'foo': 'bar'} ... but not work. within with-statement dictionary empty.
i read docs, not find solution.
any hints?
use patch.dict mock dictionary:
with patch.dict('mymodule.mydict', {'newkey': 'newvalue'}): assert mymodule.mydict == {'newkey': 'newvalue'} python mocking
No comments:
Post a Comment