pytest-dotenv
pytest-dotenv copied to clipboard
Special casing `PYTHONPATH` in pytest-dotenv?
When using pytest to test utilities (CLI) or a mix of API and utility which require setting PYTHONPATH
, the current set of affairs is not great:
- because
pytest_dotenv
updates the envvars inside the running process, it's not taken in account bysys.path
- since 7.0, pytest has added a
pythonpath
configuration entry but that only updatessys.path
, so subprocesses don't take that into account
So if one wants to avoid having to set the envvar externally, one has to hit their head on that wall until they figure that both is necessary.
Having special support for PYTHONPATH
was understandably rejected in python-dotenv (https://github.com/theskumar/python-dotenv/pull/36) but I figure pytest-dotenv
is a lot more specific, and having a coherent PYTHONPATH
& sys.path
in test contexts seems a lot more sensible in the context of pytest-ing.
NB: I also opened an issue to see if the Pytest folks would be willing to update the pythonpath feature such that it'd also update the envvar: pytest-dev/pytest#10067