def test_make_file_executable(mock_err_exit, mock_getstatusoutput,
tmpdir, test_file_name,
status, include_dir):
if include_dir:
file_path = os.path.join(tmpdir.dirname, tmpdir.basename, test_file_name)
else:
file_path = test_file_name
if test_file_name == 'no_exe_file':
os.mknod(file_path)
if test_file_name == 'exe_file':
os.mknod(file_path, 0700)
output = 'test_out'
mock_getstatusoutput.return_value = (status, output)
make_file_executable(file_path)
if test_file_name == 'exe_file':
mock_err_exit.assert_not_called()
assert os.access(file_path, os.X_OK)
if test_file_name == 'no_exe_file' and status is False:
mock_err_exit.assert_not_called()
if test_file_name == 'no_exe_file' and status is True:
mock_err_exit.assert_called()
if test_file_name == 'no_exist_file':
mock_err_exit.assert_called()
tmpdir.remove()
评论列表
文章目录