Created
April 20, 2012 21:34
-
-
Save RobSpectre/2432040 to your computer and use it in GitHub Desktop.
Failure to patch accurately
This file contains hidden or 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 unittest | |
from mock import patch | |
class Class: | |
def __init__(self): | |
self.foo = 'bar' | |
class TestClass(unittest.TestCase): | |
@patch('__main__.Class') | |
def test_class(self, MockClass): | |
mock_class = MockClass.return_value | |
mock_class.foo.return_value = 'THIS IS NOT BAR ANYMORE, SNACKY.' | |
self.assertTrue(mock_class.foo != 'bar') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment