在我的程序中,当我调用此文件名时:
msTestPrompt = r'"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\MSTest.exe"'
它不起作用,它说文件名,目录名或卷语法不正确。我已经尝试了几乎所有方法来解决这个问题,我无法让它工作,无论我对字符串做什么。提前感谢您的帮助。
编辑:这是使用文件名字符串
的内容p = subprocess.Popen([msTestPrompt, blah], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Edit2:这是blah变量:
resultsFile = "/resultsfile:" + os.path.normpath('"C:/BB1.trx"')
testSettings = "/testsettings:" + os.path.normpath('"C:/Users/bgb/Documents/Brent/Code/Visual Studio/Local.testsettings"')
testContainer = '/testcontainer:"C:\Users\bgb\Documents\Brent\Code\Visual Studio\DesignF.UnitTests\bin\Debug\DesignF-UnitTests.dll"'
blah = str(' ' + testContainer + ' ' + resultsFile + ' ' + testSettings)
答案 0 :(得分:1)
尝试:
msTestPrompt = r'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe'
如果将r
放在字符串前面,则不需要再使用反斜杠。
编辑:
如果您将blah
变量更改为:
resultsFile = r'/resultsfile:C:\BB1.trx'
testSettings = r'/testsettings:C:\Users\bgb\Documents\Brent\Code\Visual Studio\Local.testsettings'
testContainer = r'/testcontainer:C:\Users\bgb\Documents\Brent\Code\Visual Studio\DesignF.UnitTests\bin\Debug\DesignF-UnitTests.dll'
blah = str(' ' + testContainer + ' ' + resultsFile + ' ' + testSettings)