Skip to content

Instantly share code, notes, and snippets.

@dotandimet
Created December 17, 2019 14:22
Show Gist options
  • Save dotandimet/c3ddb1e40cf34f378182565869d0ff82 to your computer and use it in GitHub Desktop.
Save dotandimet/c3ddb1e40cf34f378182565869d0ff82 to your computer and use it in GitHub Desktop.
from unittest.mock import Mock, patch
import mypackage
import other
def test():
thing = mypackage.get_my_class()
thing.method = Mock()
with patch('other.get_my_class',
return_value=thing) as mock_method:
other.other_func()
thing.method.assert_called_once_with(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment