quiqua / pytest-dotenv

A py.test plugin that parses environment files before running tests
MIT License
188 stars 18 forks source link

Special casing `PYTHONPATH` in pytest-dotenv? #23

Open xmo-odoo opened 2 years ago

xmo-odoo commented 2 years ago

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:

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