It's common practice to use VSCode's launch.json
to set environment variables for running and debugging python. However if I use VSCode's "Testing" view for python testing, is there a way for the pytest or unittest scripts to use one of the configurations in launch.json
to set env vars? If not, what would be the best way to set them for VSCode's Testing?
PyTest
has pytest-env
, however my hope was that VSCode would have a consistent way to handle env vars with python, one that would not require configuration duplication or bespoke code that ties the two.
As I'm using pytest
, I ended up defining the env vars in pytest.ini
as suggested here, however as before it creates duplication with launch.json