Skip to content

Getting "pytest test discovery error for workspace" when having multiple projects in workspace #23828

Description

I typically have several projects open in VS Code, i.e. in the current workspace. They can be Python (hatch), Java (Maven), GitLab CI/CD Components etc. VS Code Python sometimes have issues with pytest discovery in non-Python projects which results in me not being able to use Test Explorer to run/debug tests.

A typical error message looks like this:

2024-07-17 14:18:20.859 [error] pytest test discovery error for workspace: /home/u30576/dev/clones/sysdev/devops/cicd-components/python

Version: 1.91.1
Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729
Date: 2024-07-09T22:08:12.169Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Linux x64 6.5.0-41-generic

Activity

  1. eleanorjboyd commented on Jul 22, 2024

    @eleanorjboyd
    Member

    Can you include more logs and either an example smaller project or the structure of your project where you are experiencing this issue with. Thanks

  2. lfvjimisola commented on Jul 22, 2024

    @lfvjimisola

    Sure.

    To reproduce what I have below:

    1. start code without any projects
    2. https://github.com/luftfartsverket/reqstool-java-annotations.git
    3. add https://github.com/luftfartsverket/reqstool-client.git

    image

    What logs do you want? Python Test Log provided below.

    I would not be surprised if there is an issue with environments (which I filed an issue for as well) due to the error message

    2024-07-22 20:02:04.963 [error] /home/u30576/.local/share/hatch/env/virtual/reqstool/Fuhv_cEo/reqstool/bin/python: No module named pytest

    2024-07-22 20:02:04.939 [info] Discover tests for workspace name: reqstool-java-annotations - uri: /home/u30576/dev/clones/sysdev/devops/documentation/requirements-tool/reqstool-java-annotations
    2024-07-22 20:02:04.940 [info] Running discovery for pytest using the new test adapter.
    2024-07-22 20:02:04.940 [info] Discover tests for workspace name: reqstool-client - uri: /home/u30576/dev/clones/github/Luftfartsverket/reqstool-client
    2024-07-22 20:02:04.940 [info] Running discovery for pytest using the new test adapter.
    2024-07-22 20:02:04.941 [info] All environment variables set for pytest discovery: ...
    2024-07-22 20:02:04.942 [warning] could not find a pixi interpreter for the interpreter at /home/u30576/.pyenv/versions/3.12.2/bin/python
    2024-07-22 20:02:04.942 [info] All environment variables set for pytest discovery: ...
    2024-07-22 20:02:04.943 [warning] could not find a pixi interpreter for the interpreter at /home/u30576/.local/share/hatch/env/virtual/reqstool/Fuhv_cEo/reqstool/bin/python
    2024-07-22 20:02:04.949 [info] > ~/.pyenv/versions/3.12.2/bin/python -m pytest -p vscode_pytest --collect-only tests --color=yes
    2024-07-22 20:02:04.949 [info] cwd: ~/dev/clones/sysdev/devops/documentation/requirements-tool/reqstool-java-annotations
    2024-07-22 20:02:04.953 [info] > ~/.local/share/hatch/env/virtual/reqstool/Fuhv_cEo/reqstool/bin/python -m pytest -p vscode_pytest --collect-only tests --color=yes
    2024-07-22 20:02:04.953 [info] cwd: ~/dev/clones/github/Luftfartsverket/reqstool-client
    2024-07-22 20:02:04.963 [error] /home/u30576/.local/share/hatch/env/virtual/reqstool/Fuhv_cEo/reqstool/bin/python: No module named pytest
    
    2024-07-22 20:02:04.965 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /home/u30576/dev/clones/github/Luftfartsverket/reqstool-client.
    2024-07-22 20:02:04.966 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /home/u30576/dev/clones/github/Luftfartsverket/reqstool-client. Creating and sending error discovery payload
    2024-07-22 20:02:04.966 [error] pytest test discovery error for workspace:  /home/u30576/dev/clones/github/Luftfartsverket/reqstool-client 
      
     The python test process was terminated before it could exit on its own, the process errored with: Code: 1, Signal: null for workspace /home/u30576/dev/clones/github/Luftfartsverket/reqstool-client
    2024-07-22 20:02:05.080 [info] �[1m============================= test session starts ==============================�[0m
    platform linux -- Python 3.12.2, pytest-8.3.1, pluggy-1.5.0
    
    2024-07-22 20:02:05.080 [info] rootdir: /home/u30576/dev/clones/sysdev/devops/documentation/requirements-tool/reqstool-java-annotations
    collected 0 items
    
    2024-07-22 20:02:05.081 [info] 
    �[33m========================= �[33mno tests collected�[0m�[33m in 0.00s�[0m�[33m ==========================�[0m
    
    2024-07-22 20:02:05.082 [error] ERROR: file or directory not found: tests
    
    
    2024-07-22 20:02:05.097 [error] Subprocess exited unsuccessfully with exit code 4 and signal null on workspace /home/u30576/dev/clones/sysdev/devops/documentation/requirements-tool/reqstool-java-annotations.
    2024-07-22 20:02:05.098 [error] Subprocess exited unsuccessfully with exit code 4 and signal null on workspace /home/u30576/dev/clones/sysdev/devops/documentation/requirements-tool/reqstool-java-annotations. Creating and sending error discovery payload
    2024-07-22 20:02:05.098 [error] pytest test discovery error for workspace:  /home/u30576/dev/clones/sysdev/devops/documentation/requirements-tool/reqstool-java-annotations 
      
     The python test process was terminated before it could exit on its own, the process errored with: Code: 4, Signal: null for workspace /home/u30576/dev/clones/sysdev/devops/documentation/requirements-tool/reqstool-java-annotations
    
  3. github-actions commented on Aug 29, 2024

    @github-actions

    Hey Eleanor Boyd (@eleanorjboyd), this issue might need further attention.

    Jimisola Laursen (@jimisola), you can help us out by closing this issue if the problem no longer exists, or adding more information.

  4. github-actions commented on Sep 29, 2024

    @github-actions

    Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

    Happy Coding!

  5. jimisola commented on Sep 29, 2024

    @jimisola
    Author

    Eleanor Boyd (@eleanorjboyd) Would be nice if you can reopen this and advise me if the supplied information is enough.

  6. eleanorjboyd commented on Sep 30, 2024

    @eleanorjboyd
    Member

    yes this should not have been closed- I will review sorry!

  7. added
    bugIssue identified by VS Code Team member as probable bug
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Dec 16, 2024
  8. eleanorjboyd commented on Sep 23, 2026

    @eleanorjboyd
    Member

    🤖 Thanks for the detailed reproduction, and apologies that this remained pending after it was reopened. Testing and environment selection have changed substantially since the 2024 report; could you confirm whether the same two-repository workspace still fails on the latest Python and Python Environments extensions, and attach the current Python Test Log plus Python: Report Issue output if it does? In particular, please note whether the non-Python folder's failure still prevents tests from the Python project appearing or running. We use the info-needed label for this confirmation, and issues with that label automatically close after 30 days without a reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-testingbugIssue identified by VS Code Team member as probable bugconfirmation pendingThe issue needs to be confirmed through a maintainer reproducing the bug.info-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions