lundi 5 octobre 2015

Appending Mock Objects to Multiprocessing Dictionary Proxy

I am trying to unit test Python 2.7 code that uses the multiprocessing module. The code uses a DictProxy from the multiprocessing module to store information. The DictProxy has keys that are integers and values that are a list of custom objects. I want to mock the custom objects.

The problem is that when I run code similar to this:

mydict = Manager().dict()
mymock = Mock()
mydict[1] = []
mydict[1].append(mymock)
print mydict[1]

I get that mydict[1] is just an empty list.

Does anyone know how to change this behavior or at least work around it?

Aucun commentaire:

Enregistrer un commentaire