I am trying to parametrize a call to pytest like this:
export OPTIONS="tests -k 'not e2e'"
pytest ${OPTIONS}
The pytest
call fails because of the quotes in the variable. Putting the options directly in the call works fine.
I tried:
pytest ${OPTIONS}
ERROR: file not found: tests -k 'not e2e'
pytest $(eval echo "${OPTIONS}") # removes all quotes
ERROR: file not found: e2e
pytest $(printf %s ${OPTIONS})
How can I make the pytest
call work in a parametrized way?
UPDATE
This answer contains a solution that works:
eval "OPTIONS=($OPTIONS)" # (opt.) convert an existing string to an array
export OPTIONS=(tests -k 'not e2e')
pytest "${OPTIONS[@]}"
Thank you very much for pointing that out. I was already searching for hours.