Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python test failing ERROR: file not found: ./test_mything_plugin.py::test_get_conn #9349

Closed
toddljones opened this issue Dec 31, 2019 · 14 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug investigating We are looking into the cause of the issue

Comments

@toddljones
Copy link

toddljones commented Dec 31, 2019

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

  1. VSCode is able to execute the tests as shown in the test discovery.
  2. VSCode adornments show in test .py files

Actual behavior

  1. Test discover works and the tests show in the Test Explorer, great!
  2. Test adornments do not show in the Text Editor window
  3. 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
@toddljones toddljones added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Dec 31, 2019
@karthiknadig karthiknadig self-assigned this Jan 2, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jan 2, 2020
@brettcannon
Copy link
Member

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
Copy link
Member

@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
Copy link
Author

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.

image

Error message in the OUTPUT Python Test Log:

============================= test session starts ==============================
platform linux -- Python 3.6.9, pytest-5.0.1, py-1.8.0, pluggy-0.13.1
rootdir: /mnt/c/users/toddl/foo
collected 0 items

-------------- generated xml file: /tmp/tmp-12862iXCV7hZDFK8.xml ---------------
========================= no tests ran in 0.07 seconds =========================
ERROR: file not found: ./test_foo.py::test_getfoo

@toddljones
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Member

#6881 may be related.

@alexdauenhauer
Copy link

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
Copy link
Author

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
Copy link

Thanks @toddljones I'll give it a shot

@GabrielSlPires
Copy link

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_lineage interestingly the path is correct.

@filiperosa
Copy link

Having the exact same issue, works for 'All Tests' but not individually.

@iynehz
Copy link

iynehz commented 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
Copy link
Member

Starting with 2021.9 (which will be released this week) we have new system manage test ux. Please try this out with that.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug investigating We are looking into the cause of the issue
Projects
None yet
Development

No branches or pull requests

8 participants