我的unittest teardown代码不会删除该文件
test_utility1.dat
我甚至试过了操作系统删除也没有运气。我不明白为什么我的进程在引发错误后仍保留文件。我在python3.6上运行它,并使用Pycharm作为我的IDE。我所有的考试都通过了,除了考试不及格。在
我的意思是我试图嘲笑,但我没有运气(新手,我只是不能理解或理解这个概念)。所以我不得不创建一个临时文件并删除它。我也有同样的问题,所以我认为如果我尝试textfixture库,效果会更好。但同样的错误。在
更新了我的帖子
请帮忙。谢谢你
prototype7.py
import sys
import pandas
def create_utility_config_dataframe(a):
cols = ['Name', 'D', 'L', 'J', 'H', 'E', 'M', 'RF', 'AF']
try:
return pandas.read_csv(a, sep='\t', usecols=cols)
except Exception as ve:
ve = (str(ve) + "\n\nPlease ensure utility config '%s' exist and is correctly formatted (tab delimited)" %a)
sys.exit(ve)
test2\u prototype7.py
^{2}$错误日志
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'test_utility1.dat'
测试效用1.dat
Name.D.L.J.H.E.M.RF.AF
line1.150.4.2.150.2.Copper.1.true
嗯,决议如下。在
初始代码片段
新代码片段
^{pr2}$这就解决了问题。这是
assertRaise
代码的问题。我不完全确定为什么,但是如果我使用with
语句,它现在可以正常工作了。在相关问题 更多 >
编程相关推荐