I'm trying to assert that a method is not called using Python Mock. Unfortunately, I can't seem to get past this error:
AttributeError: MockCallable instance has no attribute 'called'
I'm running Python 2.7.1 and Python Mock 0.1.0 for my tests. Google says: No results found for "AttributeError: MockCallable instance has no attribute 'called'".
How can I resolve this error?
Here's the test:
import unittest2
import main
from mock import Mock
class TestCli(unittest2.TestCase):
def setUp(self):
self.mockView = Mock()
self.mockFriendManager = Mock()
self.mockedCli = main.CLI(self.mockView, self.mockFriendManager)
[...]
def testCliDoesntGetFriendPropertiesWhenNotSelected(self):
view = Mock( { "requestResponse":2 } )
friendManager = Mock()
cli = main.CLI(view, friendManager)
cli.outputMenu()
assert not friendManager.getFriendProperties.called, 'hello'
You must update you
mock
library bypip
. Attributecalled
was introduced in 0.4.0 as you can see in http://www.voidspace.org.uk/python/mock/changelog.html#version-0-4-0Anyway by update it you will get a lot of more useful facilities and tools.