Closed fsackur closed 3 years ago
Thank you so much for your workaround with the .env
file. The other "fix" of setting python.testing.cwd
only fixed discovery, but broke the execution, because it was duplicating my src
folder.
Without your workaround I'm seeing
pytest-django could not find a Django project (no manage.py file could be found). You must explicitly add your Django project to the Python path to have it picked up.
although
python -m pytest /code/src --collect-only
python -m pytest /code --collect-only
both are indeed working in my dev container from whatever directory i execute that command. And i do have the python path configured in my dev container:
echo $PYTHONPATH
/code/src:
It seems to be caused by a bug here: https://github.com/kondratyev-nv/vscode-python-test-adapter/blob/bbe8f1d2d342b2a74aab762f821a3de5678d9312/src/pytest/pytestTestRunner.ts#L157-L161
environment.PYTHONPATH
is undefined for me. Replacing it with process.env.PYTHONPATH
makes it work. Not sure if this would break something else though.
Assuming you are using littlefoxteam.vscode-python-test-adapter-0.6.7, you can manually patch locally by editing the following file:
// VSCode insiders
vim ~/.vscode-server-insiders/extensions/littlefoxteam.vscode-python-test-adapter-0.6.7/out/src/pytest/pytestTestRunner.js
// VSCode
vim ~/.vscode-server/extensions/littlefoxteam.vscode-python-test-adapter-0.6.7/out/src/pytest/pytestTestRunner.js
And then change updatedPythonPath at line 124:
124 const updatedPythonPath = [
+ process.env.PYTHONPATH,
125 config.getCwd(),
126 environment.PYTHONPATH,
127 DISCOVERY_OUTPUT_PLUGIN_INFO.PACKAGE_PATH
128 ].filter(item => item).join(path.delimiter);
Great to see this fixed, thanks a lot!
@tuky JFYI I'll still need to publish a new version before this will be fixed. I'll comment on this issue after the new version will become available.
@fsackur @tuky @bergkvist I've published a new version 0.6.8, it should be available for update. Please, update and let me know if the issue persists. Thanks to @bergkvist for the fix!
Thank you, i can confirm the issue is fixed for me now.
In my remote container, still has a problem.
I install ffi python lib into /usr/local
, and export env in zshrc
, but pytest adapter can not load PATH /usr/local/python:/usr/local/lib
, Maybe need restart container?
export LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"
export PYTHONPATH="/home/workspace/nncase/tests:/usr/local/python:/usr/local/lib:${PYTHONPATH}"
run python scirpt in terminal :
run python scirpt in pytest adapter collection:
collecting ... 2021-05-27 09:03:10.900024: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/lib:
2021-05-27 09:03:10.900083: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
['/home/workspace/nncase/tests/importer', '/home/workspace/nncase', '/root/.vscode-server/extensions/ms-python.python-2021.5.842923320/pythonFiles/testing_tools', '/root/.vscode-server/extensions/ms-python.python-2021.5.842923320/pythonFiles', '/home/workspace/nncase/tests', '/home/workspace/nncase', '/root/miniconda3/lib/python37.zip', '/root/miniconda3/lib/python3.7', '/root/miniconda3/lib/python3.7/lib-dynload', '/root/miniconda3/lib/python3.7/site-packages']
collected 0 items / 24 errors
.
.
tests/test_util.py:24: in <module>
import nncase
E ModuleNotFoundError: No module named 'nncase'
Hi,
I use PYTHONPATH to set the root of my app. This works fine in the default test view, but Test Explorer isn't respecting it:
If I set up an env file, set PYTHONPATH in it, and point
python.envFile
at it, then the tests work.I can also make the tests work by setting
python.testing.cwd
to the path of my PYTHONPATH.These aren't really great workarounds for me, unfortunately.
Potentially relevant: I am developing in a dev container. The extension is installed in the container. But PYTHONPATH is baked into the image, so it's hard to understand how the extension isn't seeing it.