Skip to content

Clicking on a test in the Test Explorer does not navigate to the correct test #8448

Closed

Description

Environment data

  • VS Code version: 1.40
  • Extension version (available under the Extensions sidebar): 2019.10.44104
  • OS and version: macOS 10.14.6
  • Python version (& distribution if applicable, e.g. Anaconda): XXX
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): Python 3.7.4 venv
  • Relevant/affected Python packages and their versions: pytest 5.1.3
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): N/A

Expected behaviour

Clicking on a test in the test explorer should navigate to the correct test in the correct test file.

Actual behaviour

Clicking on a test in the test explorer navigates to the correct test file but the cursor ends up in a random place in the file.

Steps to reproduce:

  1. Have the following folder structure:
root/
   .vscode/settings.json
   hello.py
   tests/
         test_file.py

with test_file.py containing

"""Example test"""


def test_file_one():
    print("hello")
    assert True


def test_file_two():
    print("world")
    assert True

and hello.py containing print("hello world").

  1. Activate the python extension by opening hello.py
  2. Discover tests using pytest
  3. Expand the test folder structure and click on test_file_one and then test_file_two
  4. Observe that not only is the cursor not located at the def test_file_one line, but it also doesn't move when clicking on a different test.

Logs

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

> ~/Documents/Sandbox/hello-world/.venv/bin/python3 ~/.vscode/extensions/ms-python.python-2019.10.44104/pythonFiles/symbolProvider.py ~/Documents/Sandbox/hello-world/tests/test_file.py

👉 The information returned by > ~/Documents/Sandbox/hello-world/.venv/bin/python3 ~/.vscode/extensions/ms-python.python-2019.10.44104/pythonFiles/symbolProvider.py ~/Documents/Sandbox/hello-world/tests/test_file.py is correct:

{
   "classes":[],
   "methods":[],
   "functions":[
      {
         "namespace":"",
         "name":"test_file_one",
         "range":{
            "start":{
               "line":3,
               "character":0
            },
            "end":{
               "line":5,
               "character":4
            }
         }
      },
      {
         "namespace":"",
         "name":"test_file_two",
         "range":{
            "start":{
               "line":8,
               "character":0
            },
            "end":{
               "line":10,
               "character":4
            }
         }
      }
   ]
}

Activity

  1. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Nov 11, 2019
  2. brettcannon commented on Jul 29, 2021

    @brettcannon
    Member

    This is fixed in the upcoming test provider.

    Animation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-testingbugIssue identified by VS Code Team member as probable bugregressionBug didn't exist in a previous releaseverifiedVerification succeeded

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions