mardi 19 juin 2018

Patching a __new__ does not revert

I've been having this weird problem I can't solve for a couple of days now. Basically I am running a Python unit test suite for an application. At some point, in the "TestApplication" class I patch FooObject.new to return a mock and it works. Some test cases later it gets to the "TestFooObject" test class and when I attempt creating FooObject( param1, param2 ) I get

TypeError: object() takes no parameters

I've added

self.addCleanup(patcher.stop)

and I've tried stopping it myself, but it doesn't seem to work. Any ideas?

Cheers

Aucun commentaire:

Enregistrer un commentaire