Todd Jones
Todd Jones

Reputation: 499

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

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

Upvotes: 2

Views: 2080

Answers (1)

Brett Cannon
Brett Cannon

Reputation: 16080

Typically the code lenses for tests fail because either another extension interferes (e.g. gitlens) or the code isn't being picked up by IntelliSense (i.e. Jedi or the Microsoft Python Language Server). I would try turning off your other extensions and see if that solves the problem. I would also check that you get code completion in your tests files.

Upvotes: 1

Related Questions