News for hackers. Stuff that matters.
Re:Super Simple Mocking For Python by surething on Thursday February 23, 2012 @04:57AM (#3624395)
Agreed. I did the following:

    def __enter__(self):
        self.original = dict(self.obj.__dict__)
        self.obj.__dict__.update(self.mocks)
        return self

    def __exit__(self, typ, val, traceback):
        self.obj.__dict__ = self.original
This doesn't perform a deep copy, but prevents modifications on self.obj.__dict__ from modifying self.original also.

There are no comments on this comment yet.