Skip to content

add python.testing.cwd to pytest discovery if present #24384

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

Merged
merged 1 commit into from
Nov 4, 2024
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
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
Loading