我需要为写入文件的函数编写测试,如下所示:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
self.removeFromParentViewController()
//OR
self.navigationController?.popViewControllerAnimated(false)
}
当然我想避免创建文件,所以我需要monkeypatch“open”,但由于“open”不属于任何类或模块,我不知道该给出什么作为第一个参数
with open(name=ccf.status_dir_path + '/' + script_normalized, mode='w') as outfile:
outfile.write(str(datetime.datetime.now()))