我正在研究一个基本上尝试从包含所有脚本的包运行测试脚本的框架。
在我的执行驱动程序文件中:
目前我正在做的是from testscripts import testscript1
,from testscript import testscript2
等等。
我正在从sys.argv[1]
test_name = sys.argv[1]
并使用eval
函数运行该脚本。
testscript skeleton:
##testscript1.py
class testscript1:
def runTest():
{
## tests to run
}
eval函数调用:
eval(test_name+"."+test_name+".runTest()")
为此我需要单独导入每个测试脚本名称。 我想做什么,比如来自testscripts import *。
如果我这样做,那么我得到error: name 'testscript1' is not defined.
非常感谢任何帮助。