0

I'm trying to run Python tests with Tox on Windows with environmental variables like this:

set APP=c:\path\to\app\n-starting-folder\app.apk & tox -- report.xml tests/someTest.py 

And in the setUp() method i retrieve the values from environmental variables:

capabilities = {}
capabilities['app'] = os.getenv('APP')

This gives me error that the path is wrong:

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

But if I put (exactly the same) path directly into the setUp() method as a raw string literal then no error:

capabilities['app']=r'c:\path\to\app\n-starting-folder\app.apk'

So my question is: why are values from environment variables getting mangled somehow? I suspect this is because there is an "\n" in the path, but I don't know how to escape it properly.

TigerhawkT3
  • 48,464
  • 6
  • 60
  • 97
Kaarel Purde
  • 1,255
  • 4
  • 18
  • 38
  • 2
    You have a trailing space in the environment variable. Use double quotes around the argument of the `set` command: `set "APP=c:\path\to\app\n-starting-folder\app.apk"`. – Eryk Sun Aug 03 '15 at 19:13
  • 2
    Also, your suspicion about `\n` is due to misunderstanding the difference between a string object and a source-code string literal. The characters `"\n"` in a string object have no inherent significance. – Eryk Sun Aug 03 '15 at 19:21
  • @eryksun it worked! I'd accept your answer if it wasn't a comment. Also thanks for pointing out the "\n" thing, I'll look into it – Kaarel Purde Aug 03 '15 at 19:25

0 Answers0