Skip to content

Conversation

bhrutledge
Copy link

Follow-up to #17622 and #17898, attn: @karthiknadig.

I tested this using my example workspace with "python.testing.cwd" set to a sub-directory, and testpaths in pytest.ini set to a sub-directory of that.

Before this change, running all tests yields:

Running tests (pytest): /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir
Running test with arguments: --rootdir /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir --override-ini junit_family=xunit1 --junit-xml=/var/folders/bw/ttgk1hcs0k989q2yzmxkzn8c0000gp/T/tmp-69875H3gF3f2niW84.xml /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir
Current working directory: /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir
Workspace directory: /Users/bhrutledge/Dev/vscode-pytest-workspace
Run completed, parsing output
Test result not found for: ./package/test_module.py::test_function

This is because the cwd is appended as an argument, which causes pytest to ignore testpaths, which causes it to collect tests that it shouldn't, causing a collection error.

With this change, running all tests yields:

Running tests (pytest): /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir
Running test with arguments: --rootdir /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir --override-ini junit_family=xunit1 --junit-xml=/var/folders/bw/ttgk1hcs0k989q2yzmxkzn8c0000gp/T/tmp-71331owgO7UMfr1MG.xml
Current working directory: /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir
Workspace directory: /Users/bhrutledge/Dev/vscode-pytest-workspace
Run completed, parsing output
./package/test_module.py::test_function Passed

Note that cwd is no longer an argument.

It looks cwd defaults to workspaceFolder.fsPath, so this seems like a safe change.

@karthiknadig karthiknadig added the skip tests Updates to tests unnecessary label Nov 15, 2021
@karthiknadig karthiknadig merged commit f18ee60 into microsoft:main Nov 16, 2021
wesm pushed a commit to posit-dev/positron that referenced this pull request Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip tests Updates to tests unnecessary

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants