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

VSC will not recognize tests #24816

Open
elutins opened this issue Feb 14, 2025 · 6 comments
Open

VSC will not recognize tests #24816

elutins opened this issue Feb 14, 2025 · 6 comments
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@elutins
Copy link

elutins commented Feb 14, 2025

Type: Bug

Behaviour

Expected vs. Actual

Expected: VSC to correctly discover and load all test files in the Testing panel.

Actual: VSC fails to recognize any test files. VSC will attempt to find test (after re-running Tests: Refresh Tests in command pallette), but does not succeed.

Steps to reproduce:

Here is a layout of my current directory containing test files
tree

├─projects
├    |── __init__.py
├    |── subfolder1
├        ├─ __init__.py
├        ├─ subfolder2
├           |── __init__.py
├           |── test_file.py

And here is a python snippet from my settings.json

"python.testing.pytestArgs": [
        "."
    ],
    "python.testing.unittestEnabled": false,
    "python.testing.pytestEnabled": true,

I tried downgrading the Python vscode extension to version 2022.8 per this issue, but still no luck.

Diagnostic data

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

NA - no output is shown in Output Panel

User Settings


languageServer: "Pylance"

formatting
• provider: "black"
• blackArgs: "<placeholder>"

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

Extension version: 2022.8.0
VS Code version: Code 1.97.0 (Universal) (33fc5a94a3f99ebe7087e8fe79fbe1d37a251016, 2025-02-04T22:41:26.688Z)
OS version: Darwin arm64 24.3.0
Modes:

System Info
Item Value
CPUs Apple M1 Pro (10 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 4, 5, 5
Memory (System) 32.00GB (2.67GB free)
Process Argv --crash-reporter-id 40779e06-2e24-4d81-b5c4-dafb19b092f8
Screen Reader no
VM 0%
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 14, 2025
@karthiknadig
Copy link
Member

@elutins when you run pytest from the terminal is it able to find the tests?

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 14, 2025
@elutins
Copy link
Author

elutins commented Feb 14, 2025

@elutins when you run pytest from the terminal is it able to find the tests?

Yep - pytest test_file.py works as expected

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 14, 2025
@karthiknadig
Copy link
Member

@elutins From the configuration you shared "python.testing.pytestArgs": ["."] we run pytest . . Does it work if you run pytest . from the root directory?

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 14, 2025
@elutins
Copy link
Author

elutins commented Feb 14, 2025

pytest . does not work from the root directory, but pytest . from the subfolder2 directory runs as expected. I updated the python.testing.cwd parameter in my settings to read as such:

"python.testing.cwd": "${workspaceFolder}/projects/subfolder1/subfolder2"

Additionally, I am developing/running these tests inside a container that is vscode is connected to. So the above settings file refers to a environments/dev/.vscode/settings.json file, where environments is at the same level as projects . Here are the updated relevant test settings from my settings.json file

"python.testing.pytestArgs": [
        "."
    ],
    "python.testing.unittestEnabled": false,
    "python.testing.pytestEnabled": true,
    "python.testing.cwd": "${workspaceFolder}/projects/subfolder1/subfolder2"

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 14, 2025
@eleanorjboyd
Copy link
Member

did adding the cwd help? Was any output produced after that change?

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 14, 2025
@elutins
Copy link
Author

elutins commented Feb 14, 2025

adding the cwd produced the same result - tests were still not discovered

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants