Skip to content

Commit

Permalink
add python.testing.cwd to pytest discovery if present
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Nov 4, 2024
1 parent 379229a commit ea855f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ export class PytestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
traceWarn("Symlink found, adding '--rootdir' to pytestArgs only if it doesn't already exist. cwd: ", cwd);
pytestArgs = addValueIfKeyNotExist(pytestArgs, '--rootdir', cwd);
}
// if user has provided `--rootdir` then use that, otherwise add `cwd`
// root dir is required so pytest can find the relative paths and for symlinks
addValueIfKeyNotExist(pytestArgs, '--rootdir', cwd);

// get and edit env vars
const mutableEnv = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,17 @@ suite('pytest test discovery adapter', () => {

// verification

const expectedArgs = ['-m', 'pytest', '-p', 'vscode_pytest', '--collect-only', '.', 'abc', 'xyz'];
const expectedArgs = [
'-m',
'pytest',
'-p',
'vscode_pytest',
'--collect-only',
'.',
'abc',
'xyz',
`--rootdir=${expectedPathNew}`,
];
execService.verify(
(x) =>
x.execObservable(
Expand Down

0 comments on commit ea855f0

Please sign in to comment.