0

在我的程序中,当我调用此文件名时:

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)
4

1 回答 1

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)
于 2013-05-29T11:57:34.140 回答