我正在尝试在 Windows 上使用 Tox 运行 Python 测试,环境变量如下:
set APP=c:\path\to\app\n-starting-folder\app.apk & tox -- report.xml tests/someTest.py
在setUp()
方法中,我从环境变量中检索值:
capabilities = {}
capabilities['app'] = os.getenv('APP')
这给了我路径错误的错误:
error: Failed to start an Appium session, err was: Error: Bad app: c:\path\to\app\n-starting-folder\app.apk . App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Using local app, but didn't end in .zip, .ipa or .apk
但是,如果我将(完全相同)路径setUp()
作为原始字符串文字直接放入方法中,则不会出现错误:
capabilities['app']=r'c:\path\to\app\n-starting-folder\app.apk'
所以我的问题是:为什么环境变量中的值会以某种方式被破坏?我怀疑这是因为"\n"
路径中有一个,但我不知道如何正确逃避它。