Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same pytest --rootdir logic as test discovery #17898

Merged
merged 3 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/2 Fixes/9553.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Partial fix for using the same directory as discovery when running tests.
(thanks [Brian Rutledge](https://github.com/bhrutledge))
2 changes: 1 addition & 1 deletion src/client/testing/testController/pytest/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class PytestRunner implements ITestsRunner {
// if user has provided `--rootdir` then use that, otherwise add `cwd`
if (testArgs.filter((a) => a.startsWith('--rootdir')).length === 0) {
// Make sure root dir is set so pytest can find the relative paths
testArgs.splice(0, 0, '--rootdir', options.workspaceFolder.fsPath);
testArgs.splice(0, 0, '--rootdir', options.cwd);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the logic below, this should use python.testing.cwd if it's set, otherwise the --rootdir option from python.testing.pytestArgs.

return this.runner.runTests(
testRun,
{
workspaceFolder: workspace.uri,
cwd:
settings.testing.cwd && settings.testing.cwd.length > 0
? settings.testing.cwd
: workspace.uri.fsPath,
token,
args: settings.testing.pytestArgs,
},
this.idToRawData,

}

// Positional arguments control the tests to be run.
Expand Down