Last active
February 6, 2016 13:40
-
-
Save drFabio/e7c09f3d44254fb62f3d to your computer and use it in GitHub Desktop.
Utility to simplify patch.objec wen it behaves as a spy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest.mock import patch | |
def spy(target, attribute, **kwargs): | |
if kwargs.get('wraps') is None: | |
kwargs['wraps'] = getattr(target, attribute) | |
return patch.object(target, attribute , **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment