我试图断言使用Python Mock不调用方法。不幸的是,我似乎无法克服这个错误:
AttributeError: MockCallable instance has no attribute 'called'
我正在为我的测试运行Python 2.7.1和Python Mock 0.1.0。 Google说:No results found for "AttributeError: MockCallable instance has no attribute 'called'".
如何解决此错误?
以下是测试:
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'
答案 0 :(得分:1)
您必须按mock
更新pip
库。正如您在http://www.voidspace.org.uk/python/mock/changelog.html#version-0-4-0
called
无论如何通过更新它你将获得许多更有用的设施和工具。