import os
from common.readconfig import ReadConfig
class ReadCaseDate(object):
"""读取测试案例数据"""
def readcasedate(self):
allfilepath = []
self.datadir = ReadConfig() # 对ReadConfig类实例化(写的一个获取地址的类)
testdatadir = self.datadir.get_testdatadir("testdatadir") # 获取文件夹地址
allfilenames = os.listdir(testdatadir) # 获取地址下的有文件
#print(allfilenames)
#print(type(allfilenames))
# 两层查找文件循环
for filename in allfilenames:
# print(filename)
# print(type(filename))
if (filename.endswith('.xls')) or (filename.endswith('.xlsx')):
filepath = os.path.join(testdatadir, filename)
allfilepath.append(filepath)
#print(allfilepath)
else:
filesdir = os.path.join(testdatadir,filename)
files = os.listdir(filesdir)
for file in files:
if (file.endswith('.xls')) or (file.endswith('.xlsx')):
filepath = os.path.join(filesdir, file)
allfilepath.append(filepath)
else:
pass
return allfilepath
if __name__ == '__main__':
test = ReadCaseDate()
i = test.readcasedate()
print(i)