Skip to content
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
1 change: 1 addition & 0 deletions news/2 Fixes/8678.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't override user provided `--rootdir` in pytest args.
7 changes: 5 additions & 2 deletions src/client/testing/testController/pytest/arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ function pytestFilterArguments(args: string[], argumentToRemoveOrFilter: string[
'--verbosity',
'-r',
'--tb',
'--rootdir',
'--show-capture',
'--durations',
'--junit-xml',
Expand Down Expand Up @@ -277,6 +276,10 @@ export function preparePytestArgumentsForDiscovery(options: TestDiscoveryOptions
if (args.indexOf('-s') === -1) {
args.splice(0, 0, '-s');
}
args.splice(0, 0, '--rootdir', options.workspaceFolder.fsPath);

// Only add --rootdir if user has not already provided one
if (args.filter((a) => a.startsWith('--rootdir')).length === 0) {
args.splice(0, 0, '--rootdir', options.cwd);
}
return args;
}
7 changes: 5 additions & 2 deletions src/client/testing/testController/pytest/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ export class PytestRunner implements ITestsRunner {
// Ensure that we use the xunit1 format.
testArgs.splice(0, 0, '--override-ini', 'junit_family=xunit1');

// Make sure root dir is set so pytest can find the relative paths
testArgs.splice(0, 0, '--rootdir', options.workspaceFolder.fsPath);
// 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);
}

// Positional arguments control the tests to be run.
const rawData = idToRawData.get(testNode.id);
Expand Down