Skip to content

python.testing.cwd ignored when discovering or running tests using unittest #11425

@Ark-kun

Description

@Ark-kun

The issues is similar to #8678 , but is about unittest, not pytest

Environment data

  • VS Code version: 1.44.0
  • Extension version: 2020.4.74986
  • OS and version: Windows 10 Pro 1903
  • Python version: python 3.7.4 x64
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A
  • Relevant/affected Python-related VS Code extensions and their versions: N/A
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): True
  • Value of the python.languageServer setting: Microsoft

Expected behaviour

Set python.testing.cwd to correct directory in Workspace settings.
Try discovering tests.
The test discovery uses the provided cwd.

Actual behaviour

The test discovery ignores the provided cwd.

Output for Python in the Output panel:

Here is what I see during test discovery:
(My python.testing.cwd is set to "sdk/python" or "<workspace_root>/sdk/python").

> .../python ...\.vscode\extensions\ms-python.python-2020.4.74986\pythonFiles\pyvsc-run-isolated.py -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="*test*.py")
print("start") #Don't remove this line
for suite in suites._tests:
    for cls in suite._tests:
        try:
            for m in cls._tests:
                print(m.id())
        except:
            pass"
cwd: <workspace_root>

See how the bottom line prints a different value of cwd.

P.S. I'm seeing the above log twice every time I try discovering the tests...

Metadata

Metadata

Assignees

Labels

bugIssue 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