Auty自動化測試框架第一篇——生成執行列表


[本文出自天外歸雲的博客園]

在Auty的scripts文件夾中編寫一個create_selection.py文件,用於在同級目錄下針對同級目錄scripts下的所有腳本生成一個selection.txt文件,其中包含所有同級目錄scripts文件夾下可執行的python腳本:

代碼如下:

# -*- coding: utf-8 -*-
import sys
import os

def create_selection():
    path = sys.path[0]
    selection = []
    for i in os.walk(os.path.join(path,'scripts')):
        for fileName in i[2:3][0]:
            filePath = os.path.join(i[0],fileName)
            if(check_if_python(filePath)):
                selection.append(filePath)
    return selection

def check_if_python(fileName):
    if fileName.endswith('.py'):
        return True

def create_selection_file(selection):
    filePath = os.path.join(sys.path[0],'all_scripts_selection.txt')
    theFile = open(filePath,'w')
    for scriptPath in selection:
        theFile.write(scriptPath+'\n')
    theFile.close()

if __name__ == '__main__':
    selection = create_selection()
    create_selection_file(selection)

執行這個腳本,就會生成所有可以執行的腳本文件列表。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM