我正在测试一些python代码,当我用指定的文件运行nosetests时,一切正常,但是当我想运行文件夹中的所有东西时,一些测试(大多数)失败了。你知道吗
我在python2.7中使用mock、unittest和nose
谢谢
例如:
AssertionError: Expected call: mock('fake/path')
Not called
在这个测试中
def test_vm_exists(self):
fake_path = 'fake/path'
os.path.exists = mock.MagicMock()
os.path.exists.return_value = True
response = self._VixConnection.vm_exists(fake_path)
os.path.exists.assert_called_with(fake_path)
self.assertEqual(response, True)
这是回购: https://github.com/trobert2/nova-vix-driver/tree/unittests/vix/tests
如果描述得不够详细,我很抱歉。你知道吗
实际上,您并不是在模仿实际代码使用的
os.path.exists
。请尝试以下操作:相关问题 更多 >
编程相关推荐