0

I am trying to run python tests via pytest on a Windows machine. There is a shell script in this repository which contains a line of input to do so:

env $(cat ../env.example | xargs) pytest $@

As I understand it, this retrieves environment variables from env.example (located in the parent directory from where the tests live), builds them into an argument package xargs, and passes the arguments with the pytest command to the tests script.

This does not work on Windows, obviously. Namely because env and xargs are not native. I know that set works similarly to env. Aside from that, what would be the equivalent input to run these tests with the desired environment variables on my machine?

  • 1
    The proper Unix shell script would use `"$@"`. This is a common error. See [When to wrap quotes around a shell variable?](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable) (Also, avoid the [useless `cat`.](https://stackoverflow.com/questions/11710552/useless-use-of-cat)) – tripleee Feb 09 '23 at 20:44
  • 1
    Perhaps the best solution is to use python instead. What is in that env.example? This seems like a complicated way to run a command. As a note, `../env.example` references the current working directory, which wouldn't be the parent of the tests unless you've cd'd there. – tdelaney Feb 09 '23 at 21:14

0 Answers0