Skip to content

Pytest doesn't work with python workspaces #1209

Open
@glenclayton

Description

Bug description

When using the workspace-python-3.12 image, pytest discovery doesn't work as the pytest module isn't found

2023-10-21 14:26:43.442 [error] Error discovering pytest tests:
[n [Error]: Traceback (most recent call last):
File "/workspace/.vscode-remote/extensions/ms-python.python-2023.18.0-universal/pythonFiles/testing_tools/run_adapter.py", line 17, in
from testing_tools.adapter.main import parse_args, main
File "/workspace/.vscode-remote/extensions/ms-python.python-2023.18.0-universal/pythonFiles/testing_tools/adapter/main.py", line 9, in
from . import pytest, report
File "/workspace/.vscode-remote/extensions/ms-python.python-2023.18.0-universal/pythonFiles/testing_tools/adapter/pytest/init.py", line 7, in
from ._discovery import discover # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/.vscode-remote/extensions/ms-python.python-2023.18.0-universal/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 8, in
import pytest
ModuleNotFoundError: No module named 'pytest'

Steps to reproduce

  1. https://gitpod.io/new#https://github.com/glenclayton/gitpod_pytest/tree/python_workspace
  2. Click on Testing
  3. Observe discovery fails and the error message above in Output->Python

Expected behavior

Using the workspace-full or default images works

  1. https://gitpod.io/new#https://github.com/glenclayton/gitpod_pytest
  2. Click on Testing
  3. Observe test is discovered and can be run

Example repository

  1. https://github.com/glenclayton/gitpod_pytest - works as expected
  2. https://github.com/glenclayton/gitpod_pytest/tree/python_workspace - fails test disovery

Anything else?

No response

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingteam: team-experienceBelonging to the Experience team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions