我试图断言没有使用 Python Mock 调用方法。不幸的是,我似乎无法克服这个错误:
AttributeError: MockCallable instance has no attribute 'called'
我正在为我的测试运行 Python 2.7.1 和 Python Mock 0.1.0。谷歌说: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'