Skip to content

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

Closed

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

  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

Activity

  1. added
    triage-neededNeeds assignment to the proper sub-team
    bugIssue identified by VS Code Team member as probable bug
    on Dec 31, 2019
  2. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Jan 2, 2020
  3. brettcannon commented on Jan 7, 2020

    @brettcannon
    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.

  4. karthiknadig commented on Jan 7, 2020

    @karthiknadig
    Member

    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.

  5. toddljones commented on Jan 7, 2020

    @toddljones
    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
    
  6. toddljones commented on Jan 7, 2020

    @toddljones
    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.

  7. toddljones commented on Jan 7, 2020

    @toddljones
    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

  8. toddljones commented on Jan 8, 2020

    @toddljones
    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.

  9. ericsnowcurrently commented on Jan 8, 2020

    @ericsnowcurrently

    #6881 may be related.

  10. alexdauenhauer commented on Apr 12, 2021

    @alexdauenhauer

    I have the same error running on macOS. I can execute pytest from the command line perfectly fine, but cannot run in vs code.

  11. toddljones commented on Apr 13, 2021

    @toddljones
    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.

  12. alexdauenhauer commented on Apr 14, 2021

    @alexdauenhauer

    Thanks Todd Jones (@toddljones) I'll give it a shot

  13. GabrielSlPires commented on Jul 16, 2021

    @GabrielSlPires

    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.

  14. filiperosa commented on Jul 19, 2021

    @filiperosa

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

  15. iynehz commented on Aug 16, 2021

    @iynehz

    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

  16. karthiknadig commented on Sep 2, 2021

    @karthiknadig
    Member

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

  17. locked as resolved and limited conversation to collaborators on Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable buginvestigatingWe are looking into the cause of the issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions