Open talebia opened 3 days ago
@talebia Can you check if the vscode_pytest
exists in the extensions directory? You can find the extensions directory by running this command:
Then open the folder that starts with ms-python.python
. In that directory there should be python_files
directory, open it. There you should find vscode_pytest
:
Make sure that this folder exists. If it does not exit, try uninstalling python extension, close all vscode instances, and reopen vs code and install python extension again.
@karthiknadig I do seem to have it although slightly different version that above:
That looks correct. In the logs you pasted, it looks like the environment variables were truncated, can you make sure it has PYTHONPATH
set to:
I can set the env var and it works fine. though would I have to update it manually each time there's a new version? plus I'm not sure why it was not set in the first place..
@talebia You should not have to set this, it should set automatically. It looked like in the logs only TEST_RUN_PIPE
got set, the PYTHONPATH
did not. This might be a bug.
Thanks for all the info above, very weird the env vars are not getting set correctly. @talebia could you describe your setup? ie are you on a remote machine, what type of machine you have, where is this folder you are running test discovery on located. I am seeing in your logs 2024-11-11 12:17:09.165 [warning] The cwd resolves to a different path, checking if it has a symbolic link somewhere in its path.
which means the realpath of the cwd is not the cwd (it evaluates to something else) but it does not find a symlink in the cwd so I am trying to think what scenario it might be and if thats related
One thing to try that just came to mind- could you disable pytest and enable unittest instead and trying running discovery that way? To do so update your settings.json for your workspace:
"python.testing.unittestArgs": ["-v", "-s", ".", "-p", "*test*.py"],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
now RELOAD the VS Code window (important step to make sure the setting gets updated correctly)
then attempt to discover a unittest, which you can use this example if you don't have one.
import unittest
class TestExample(unittest.TestCase):
def test_true_unittest(self):
assert True
see how that goes as unittest uses the same env var substitution but with some small changes
similar to 23192 I'm using python 3.10.10 and below are the logs:
Similarly can get around it by using something like this but not sustainable.