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

Test discovery in pythonTestAdapter experiment breaks if folder names repeat #21423

Closed
ulasozguler opened this issue Jun 13, 2023 · 5 comments · Fixed by #21433
Closed

Test discovery in pythonTestAdapter experiment breaks if folder names repeat #21423

ulasozguler opened this issue Jun 13, 2023 · 5 comments · Fixed by #21433
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@ulasozguler
Copy link

ulasozguler commented Jun 13, 2023

Type: Bug

Behaviour

Expected vs. Actual

If there is a repeating name in a path, like a/b/a/test_hello.py, test discovery will fail.
pytest (and old test adapter) can handle this, so I expect it to work.

Steps to reproduce:

  1. Create a new project with a new profile. Install only Python extension.
  2. Enable pythonTestAdapter experiment.
  3. Create a new folder path a/b/a.
  4. Create a file named test_hello.py in a/b/a and write a test function in it. E.g.:
def test_say_hello():
    pass
  1. Create a virtualenv and install pytest:
python -m venv .venv
source .venv/bin/activate
pip install pytest
  1. Set virtualenv python as the selected interpreter.
  2. Go to "Testing" tab from left menu and setup pytest.
  3. Discovery will fail.
  4. If a/b/a is changed to something like a/b/c, test discovery works.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.9
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2023-06-14 00:44:18.536 [info] Discover tests for workspace name: tmpdel - uri: /Users/uls/Desktop/tmpdel/tests/a/b/a/test_hello.py
2023-06-14 00:44:18.537 [info] Running discovery for pytest using the new test adapter.
2023-06-14 00:44:18.543 [info] Discovering pytest tests with arguments: -m pytest -p vscode_pytest --collect-only tests
2023-06-14 00:44:18.543 [info] > ./.venv/bin/python -m pytest -p vscode_pytest --collect-only tests
2023-06-14 00:44:18.543 [info] cwd: .
2023-06-14 00:44:18.730 [info] Test server connected to a client.
2023-06-14 00:44:18.730 [error] pytest test discovery error 
 undefined

User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

experiments
• optInto: ["pythonTestAdapter"]

Extension version: 2023.10.0
VS Code version: Code 1.79.0 (b380da4ef1ee00e224a15c1d4d9793e27c2b6302, 2023-06-07T14:31:03.317Z)
OS version: Darwin arm64 22.5.0
Modes:

System Info
Item Value
CPUs Apple M1 Pro (8 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 3, 4, 4
Memory (System) 16.00GB (0.04GB free)
Process Argv
Screen Reader no
VM 0%
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jun 13, 2023
@ulasozguler ulasozguler changed the title Tests discovery in pythonTestAdapter experiment breaks if folder names repeat Test discovery in pythonTestAdapter experiment breaks if folder names repeat Jun 13, 2023
@eleanorjboyd
Copy link
Member

Hello! Thank you for taking the time to write a detailed issue and also for using our new experiment pythonTestAdapter, it is users like you on insiders who help keep vscode amazing for all users. I repro-ed the issue and have put in a fix. It will come out in tomorrow insiders, would you be able to test it tomorrow to see if it works for you? Thanks!

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Jun 14, 2023
@eleanorjboyd eleanorjboyd added bug Issue identified by VS Code Team member as probable bug area-testing and removed info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team labels Jun 14, 2023
@ulasozguler
Copy link
Author

ulasozguler commented Jun 15, 2023

EDIT: Never mind, I though your branch was merged. I'll try again when it does.


@eleanorjboyd Just tried again with the new version and tests are not visible on UI.

Python log
2023-06-15 16:24:54.759 [info] Discover tests for workspace name: tmpdel - uri: /Users/uls/Desktop/tmpdel
2023-06-15 16:24:54.759 [info] Running discovery for pytest using the new test adapter.
2023-06-15 16:24:54.762 [info] Discovering pytest tests with arguments: -m pytest -p vscode_pytest --collect-only .
2023-06-15 16:24:54.762 [info] > ./.venv/bin/python -m pytest -p vscode_pytest --collect-only .
2023-06-15 16:24:54.762 [info] cwd: .
2023-06-15 16:24:54.965 [info] Test server connected to a client.

Screenshot:
Screenshot 2023-06-15 at 16 24 40

When I try to run tests in this state, it gets stuck in "Running tests..." indefinitely.

eleanorjboyd added a commit that referenced this issue Jun 15, 2023
fixes #21423

fixes so the dictionary that stores the folders created so far in the
plugin architecture is using the folder path as the key instead of
folder name so the key is always unique.
@eleanorjboyd
Copy link
Member

Hi sorry- the change did not get merged till this morning so it will not be out until tomorrow (friday). Thanks!

@ulasozguler
Copy link
Author

I can confirm this is working now. Thanks!

@eleanorjboyd
Copy link
Member

Great!! Thank you so much for checking!

@eleanorjboyd eleanorjboyd added the verified Verification succeeded label Jun 16, 2023
@eleanorjboyd eleanorjboyd added this to the June 2023 milestone Jun 16, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants