test_path.py 文件源码

python
阅读 48 收藏 0 点赞 0 评论 0

项目:scarlett_os 作者: bossjones 项目源码 文件源码
def test_dir_isWritable(self, path_mocker_stopall):
        # mock
        mock_os_access = path_mocker_stopall.MagicMock(name="mock_os_access")
        mock_os_path_isdir = path_mocker_stopall.MagicMock(name="mock_os_path_isdir")
        # patch
        path_mocker_stopall.patch.object(scarlett_os.internal.path.os, 'access', mock_os_access)
        path_mocker_stopall.patch.object(scarlett_os.internal.path.os.path, 'isdir', mock_os_path_isdir)

        path = 'file:///tmp'

        # patch return values
        mock_os_path_isdir.return_value = True
        mock_os_access.return_value = True

        # run test
        result = s_path.isWritable(path)

        # tests
        mock_os_path_isdir.assert_called_once_with('file:///tmp')
        mock_os_access.assert_called_once_with('file:///tmp', os.W_OK)
        assert result == True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号