kondratyev-nv / vscode-python-test-adapter

Python Test Adapter for the VS Code Test Explorer
https://marketplace.visualstudio.com/items?itemName=LittleFoxTeam.vscode-python-test-adapter
MIT License
117 stars 27 forks source link

Able to find tests but running tests on the wrong path #284

Open rylew1 opened 1 year ago

rylew1 commented 1 year ago

Tests are found by the extension - but when I try to run them, they're being run at the wrong path. I'm using a Poetry venv in the default cache dir.

All tests are under: /Users/me/Desktop/myproject/api/tests

How the test is being called when I try to run them (missing API folder): /Users/me/Desktop/myproject/tests

From the Python Test Adapter Log:

INFO pytest at 'myproject': Running pytest with arguments: --rootdir=/Users/me/Desktop/myproject , Users/me/Desktop/project/tests/db/queries/my_test.py::test_fn

INFO pytest at 'myproject': Running /Users/me/Library/Caches/pypoetry/virtualenvs/myproject-api-NEejG4ix-py3.9/bin/pytest as an executable

CRIT pytest at 'myproject': Execution of the test Users/me/Desktop/project/tests/db/queries/my_test.py::test_fn" failed: Error: Process exited with code 4: ERROR: file or directory not found: 

VSCode Settings:

  "python.testing.pytestPath": "/Users/me/Library/Caches/pypoetry/virtualenvs/myproject-api-NEejG4ix-py3.9/bin/pytest", 
  "python.testing.unittestEnabled": false,
  "python.testing.pytestEnabled": true,
  "python.testing.pytestArgs": ["api/tests"],
sunerpy commented 11 months ago

The same with me.

Wrong output:

2023-08-05T09:01:43.610Z INFO pytest at 'syncagent': Running pytest with arguments: --rootdir=/config/workspace/ProdDir/syncagent, --junitxml=/tmp/tmp-28125-l5ggf3levPkj, --override-ini, junit_family=xunit1, /config/workspace/ProdDir/syncagent/test_tecls.py
2023-08-05T09:01:43.610Z INFO pytest at 'syncagent': Running pytest as a Python module
2023-08-05T09:01:43.816Z CRIT pytest at 'syncagent': Execution of the test "/config/workspace/ProdDir/syncagent/test_tecls.py" failed: Error: Process exited with code 4: ERROR: file or directory not found: /config/workspace/ProdDir/syncagent/test_tecls.py

In fact, it's path is: /config/workspace/ProdDir/syncagent/pytest_dir/test_tecls.py