-
-
Save beyoung/31cea1b544c67b009a4b36dd8ad9c3be to your computer and use it in GitHub Desktop.
How to mock an object property in Python
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
import mock | |
with mock.patch('path.to.ObjectClass.my_property', new_callable=mock.PropertyMock) as mock_my_property: | |
mock_my_property.return_value = 'my value' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment