我是编写python单元测试的新手,请帮助我为下面的函数编写测试用例,该函数只有print语句而不是return语句
import os
from pwd import getpwuid
from grp import getgrgid
import time
def info(self):
if self.f: // if -f flag pass with file names then it will be trigger
for i in self.f:
owner = getpwuid(os.stat(i).st_uid).pw_name
group = getgrgid(os.stat(i).st_gid).gr_name
per = oct(os.stat(i).st_mode)[-3:]
t = os.stat(i).st_mtime
print("{} is owned by: {} , group by {} with "
"permission {} and last modified on {}"
.format(i, owner, group, per, time.ctime(t)))
您可以使用contextlib的^{}
相关问题 更多 >
编程相关推荐