Open jimklo opened 4 years ago
I believe I found the problem that is effecting me.
This could be construed as a "bug" or not... I'm not entirely sure what the right solution is here, as the current implementation is not portable across IDEs.
It turns out... I also had PYTHONPATH
defined in my .env
file.
According to the official Python documentation for PYTHONPATH, is used to augment the default search path for module files. It's not clear if this is append or replace.
This EnvFile plugin, which is essentially replicating functionality that exists in Webpack, VS Code, and other bundling solutions. With VS Code, which is an IDE as opposed to a bundler, it possible that EnvFiles should treat PYTHONPATH
in a similar manner, where PYTHONPATH
within .env
specifies additional locations where the Python interpreter should look for modules.
Were you able to find a suitable workaround?
Changing the order of the .env files in the "EnvFile" configuration panel fix it for me.
Just make your ".env" file first and "
So I create test file,
test_stuff.py
and define the following test:I create a
.env
file with the following:Then I right click on the test file and select: "Run 'pytest in test_stuff...". Test runs, and fails as MY_ENV_VAR isn't defined.
I go an edit the test configuration, select the EnvFile tab, enable EnvFile plugin and add the
.env
file I created to the configuration. I click "Apply" and "OK".I then re-run the test. I expect it should pass, instead... I get the following error:
I'm not quite sure what's going on, but it seems like when EnvFile loads, it mangles the
sys.path
preventing the test runner from locating packages it needs to run.Here's the troubleshooting info from my environment: