Repository navigation
Python test failing ERROR: file not found: ./test_mything_plugin.py::test_get_conn #9349
Copy link
Copy link
Closed
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buginvestigatingWe are looking into the cause of the issueWe are looking into the cause of the issue
Description
very similar to issue #8222 on the vscode-python github.com issues list, but that thread seemed dead, so I am opening a new one
Environment Data
VSCode install
Version: 1.39.2 (user setup)
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-15T15:35:18.241Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 6.1.7601
VSCode Remote - SSH
I am using VSCode Remote - SSH to do all dev and testing on a remote linux system, version 0.48.0
VSCode Extensions
Using only the VSCode Python extension ms-python.python version 2019.11.50794
I used to use the python test extension but that capability is now absorbed into the python extension, which is great
VSCode project settings.json
{
"python.pythonPath": "/local/me/opt/miniconda3/envs/deathstar/bin/python",
"python.testing.pytestArgs": [
"test",
"--disable-warnings",
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
}
Python
$ python --version
Python 3.6.8 :: Anaconda, Inc.
$ python -c "import pytest;print(pytest.__version__)"
5.3.1
Expected behavior
- VSCode is able to execute the tests as shown in the test discovery.
- VSCode adornments show in test .py files
Actual behavior
- Test discover works and the tests show in the Test Explorer, great!
- Test adornments do not show in the Text Editor window
- When running a test, the test file, which was already discovered, cannot be found and the test execution fails out with stack trace in DEBUG CONSOLE
============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-5.3.1, py-1.8.1, pluggy-0.13.1
rootdir: /home/me/project/project_name
collected 0 items
-------------- generated xml file: /tmp/tmp-304736fTj9ikMPptk.xml --------------
============================== 1 warning in 0.01s ==============================
ERROR: file not found: ./test_mything_plugin.py::test_get_conn
Output
Developer Tools Console
[Extension Host] Info Python Extension: 2019-12-31 20:10:20: Cached data exists ActivatedEnvironmentVariables, /home/tjones/project/airflow_etl
console.ts:137 [Extension Host] Info Python Extension: 2019-12-31 20:10:20: getActivatedEnvironmentVariables, Class name = b, completed in 1ms, Arg 1: <Uri:/home/tjones/project/airflow_etl>, Arg 2: undefined, Arg 3: undefined
console.ts:137 [Extension Host] Info Python Extension: 2019-12-31 20:10:20: > /local/tjones/opt/miniconda3/envs/airflow/bin/python -m pytest --rootdir ~/project/airflow_etl --junitxml=/tmp/tmp-1575s6J3FtN4Ho55.xml --disable-warnings ./test_bam_ctds_plugin.py::test_get_conn
console.ts:137 [Extension Host] Info Python Extension: 2019-12-31 20:10:20: cwd: ~/project/airflow_etl
Python Output
_when I hit the debug button, I get nothing, but when I hit the Play button, I get this
> /local/tjones/opt/miniconda3/envs/airflow/bin/python -m pytest --rootdir ~/project/airflow_etl --junitxml=/tmp/tmp-1575D8SX75zh6k5j.xml --disable-warnings ./test_bam_ctds_plugin.py::test_get_conn
cwd: ~/project/airflow_etl
> /local/tjones/opt/miniconda3/envs/airflow/bin/python -m pytest --rootdir ~/project/airflow_etl --junitxml=/tmp/tmp-1575s6J3FtN4Ho55.xml --disable-warnings ./test_bam_ctds_plugin.py::test_get_conn
cwd: ~/project/airflow_etl
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buginvestigatingWe are looking into the cause of the issueWe are looking into the cause of the issue
Activity
brettcannon commentedon Jan 7, 2020
Thanks for the bug report! We just wanted to quickly acknowledge we received it and we will triage this as soon as we can.
karthiknadig commentedon Jan 7, 2020
Todd Jones (@toddljones) Can you share the layout of your workspace folder? I want to understand where the test file is with respect to the current working directory.
toddljones commentedon Jan 7, 2020
I just created a mock project to simplify things and so as to not share my project info. I started with a new WSL session and launched code from there. I built a minimal python venv using conda then added a foo.py and test/test_foo.py file with just your basic guts. I ran the configure tests function.
Then when I pressed play on the test I got the file not found error. Also the annotations are missing from the test_foo.py file.
Error message in the OUTPUT Python Test Log:
toddljones commentedon Jan 7, 2020
I just validated that screen shot got posted well. I believe you can see every line of my project there, both py files, and the settings.json for the workspace.
toddljones commentedon Jan 7, 2020
Environments I've tried this project in:
Windows running remote - ssh connection to linux - FAILED
Windows running WSL Ubuntu 18.04 - FAILED
Linux - PASSED
toddljones commentedon Jan 8, 2020
Interestingly, this works fine if I press the Play All button at the top, it's only when I Play an individual test that I get the error.
ericsnowcurrently commentedon Jan 8, 2020
#6881 may be related.
alexdauenhauer commentedon Apr 12, 2021
I have the same error running on macOS. I can execute pytest from the command line perfectly fine, but cannot run in vs code.
toddljones commentedon Apr 13, 2021
Hey Alex, I'm still not 100% clear on why the above was failing. But in another project I have, I was using symlinks and this caused quite a few issues. Once I moved away from all the symlinking, all the VSCode test features started working.
alexdauenhauer commentedon Apr 14, 2021
Thanks Todd Jones (@toddljones) I'll give it a shot
GabrielSlPires commentedon Jul 16, 2021
I have the same error in here. When I press the button "Run All Tests" it works fine. But when I try to run individual tests I received the error
ERROR: file or directory not found: ./root-ceua/tests/test_admin.py::test_update_lineageinterestingly the path is correct.filiperosa commentedon Jul 19, 2021
Having the exact same issue, works for 'All Tests' but not individually.
iynehz commentedon Aug 16, 2021
Having something similar to this. In our case turns out that it relates to the fact that we are using symlink as workspace dir. And this vscode-python extension's pytest test discovery hits a pytest issue that it gets wrong info about test file paths when workspace dir is a symlink. See also ticket I created to pytest pytest-dev/pytest#9008
karthiknadig commentedon Sep 2, 2021
Starting with 2021.9 (which will be released this week) we have new system manage test ux. Please try this out with that.