我想从MSTest项目中调用Python脚本。我也想将参数传递给python脚本。我写了下面的代码:
ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(null);
ScriptRuntime runtime = new ScriptRuntime(setup);
ScriptEngine engine = Python.GetEngine(runtime);
ScriptSource source = engine.CreateScriptSourceFromFile("C:\\Scripts\\main.py");
ScriptScope scope = engine.CreateScope();
List<String> argv = new List<String>();
argv.Add("T,209");
engine.GetSysModule().SetVariable("argv", argv);
source.Execute(scope);
此脚本因抛出错误而失败:没有名为List_Tables的模块
在main.py文件中,List_Tables的代码如下所示:
from List_Tables import *
from SourceConnection import *
import os
import sys
def main():
--statements--
如何解决此问题?
如何在MSTest项目中添加python项目引用?
谢谢。