Skip to content

Running all Pytest tests no longer respects pytest.ini testpaths #17546

@MetRonnie

Description

@MetRonnie

Environment data

  • VS Code version: 1.59.1
  • Extension version (available under the Extensions sidebar): v2021.9.1246542782
  • OS and version: Linux x64 3.10.0-1160.41.1.el7.x86_64
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.0 (conda-forge)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: Pytest 6.2.5
  • Relevant/affected Python-related VS Code extensions and their versions: N/A
  • Value of the python.languageServer setting: Pylance

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

Clicking the "run all tests" button in the testing sidebar (a.k.a. test explorer) should run pytest without specifying a path, respecting the testpaths setting from pytest.ini.

From looking at backups of previous Python logs before the recent update to the extension, this is what would get called

> python -m pytest --rootdir ~/myproject

(I've removed extraneous absolute paths and options)

Actual behaviour

It passes the root dir path to pytest. In the Python log:

> python -m pytest --rootdir ~/myproject ~/myproject

This is a problem because I can't run the tests successfully like this. I get ModuleNotFoundErrors as it tries to collect stuff it doesn't need.

Steps to reproduce:

  1. Have a Python project with testpaths set in pytest.ini
  2. Click the "run all tests" button

Logs

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

> ~/miniconda3/envs/<env-name>/bin/python -m pytest --rootdir <$HOME>/myproject --override-ini junit_family=xunit1 --junit-xml=/var/tmp/tmp-<rnd>.xml "-n 4" --disable-warnings -vv <$HOME>/myproject

Metadata

Metadata

Assignees

Labels

area-testingbugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions