trouble executing Selenium python unittests in C# with ScriptEngine (.NET 3.5)

霸气de小男生 提交于 2019-12-01 06:37:42

Looking at the source code to the IronPython Console (ipy.exe), it looks like it eventually boils down to calling ScriptSource.ExecuteProgram(). You can get a ScriptSource from any of the various ScriptEngine.CreateScriptSourceFrom* methods.

For example:

import clr
clr.AddReference("IronPython")

from IronPython.Hosting import Python
engine = Python.CreateEngine()
src = engine.CreateScriptSourceFromString("""
if __name__ == "__main__":
    print "this is __main__"
""")

src.ExecuteProgram()

Running this will print "this is main".

Try the following:

unittest.main(module=__name__)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!