Skip to content
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1374370
hel
Apr 7, 2023
9f67fbe
Merge branch 'microsoft:main' into main
eleanorjboyd Apr 11, 2023
69c100a
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
6403d20
Attempt to fix pre-release build (#21071)
Apr 17, 2023
a1f5041
Use new logging API for python extension logger and LS logger (#21062)
karthiknadig Apr 17, 2023
3217420
Direct users to the Jupyter extension when using Run in Interactive w…
Apr 18, 2023
540658b
Add quick pick hover support to explain conda environment lacking a P…
Apr 18, 2023
b377503
Python test execution simple (#21053)
eleanorjboyd Apr 18, 2023
8223362
Add black to `extensions.json` (#20912)
cpinamtz Apr 18, 2023
b19126e
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
72d210f
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
7dbe187
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
1bf0450
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
c95b095
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
7e5f2b4
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
b9466cc
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
bf3ad2c
Merge pull request #8 from eleanorjboyd/new-main
eleanorjboyd Apr 19, 2023
867a44e
Default to `--no-cov` when debugging pytest (#21048)
aidoskanapyanov Apr 19, 2023
55b85bb
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
10f35f6
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
c5c2994
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
8147718
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
d5637d5
Merge pull request #8 from eleanorjboyd/new-main
eleanorjboyd Apr 19, 2023
61efb05
Create environment proposed API (#21074)
karthiknadig Apr 19, 2023
3aa8b55
Deprecate python logging level setting (#21083)
karthiknadig Apr 19, 2023
d4bd6dd
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
87cffd2
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
2e42083
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
8b6abfa
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
e9a2b97
Merge pull request #8 from eleanorjboyd/new-main
eleanorjboyd Apr 19, 2023
703de32
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
2f16aae
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
5fc3e9e
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
582d780
Merge pull request #7 from eleanorjboyd/fix-main
eleanorjboyd Apr 17, 2023
cc46906
Merge pull request #8 from eleanorjboyd/new-main
eleanorjboyd Apr 19, 2023
1ac673e
Merge branch 'microsoft:main' into main
eleanorjboyd Apr 19, 2023
073c5e7
Merge branch 'microsoft:main' into main
eleanorjboyd Apr 19, 2023
ca326c2
fix pytest execution args
eleanorjboyd Apr 20, 2023
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
30 changes: 25 additions & 5 deletions src/client/testing/testController/pytest/pytestExecutionAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

import { Uri } from 'vscode';
import path from 'path';
import * as path from 'path';
import { IConfigurationService, ITestOutputChannel } from '../../../common/types';
import { createDeferred, Deferred } from '../../../common/utils/async';
import { traceVerbose } from '../../../logging';
Expand All @@ -13,7 +13,10 @@ import {
SpawnOptions,
} from '../../../common/process/types';
import { EXTENSION_ROOT_DIR } from '../../../constants';
import { removePositionalFoldersAndFiles } from './arguments';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(global as any).EXTENSION_ROOT_DIR = EXTENSION_ROOT_DIR;
/**
* Wrapper Class for pytest test execution. This is where we call `runTestCommand`?
*/
Expand Down Expand Up @@ -93,12 +96,29 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
// need to check what will happen in the exec service is NOT defined and is null
const execService = await executionFactory?.createActivatedEnvironment(creationOptions);

const testIdsString = testIds.join(' ');
console.debug('what to do with debug bool?', debugBool);
try {
execService?.exec(['-m', 'pytest', '-p', 'vscode_pytest', testIdsString].concat(pytestArgs), spawnOptions);
// Remove positional test folders and files, we will add as needed per node
const testArgs = removePositionalFoldersAndFiles(pytestArgs);

// 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', uri.fsPath);
}

if (debugBool && !testArgs.some((a) => a.startsWith('--capture') || a === '-s')) {
testArgs.push('--capture', 'no');
}

console.debug(`Running test with arguments: ${testArgs.join(' ')}\r\n`);
console.debug(`Current working directory: ${uri.fsPath}\r\n`);

const argArray = ['-m', 'pytest', '-p', 'vscode_pytest'].concat(testArgs).concat(testIds);
console.debug('argArray', argArray);
execService?.exec(argArray, spawnOptions);
} catch (ex) {
console.error(ex);
console.debug(`Error while running tests: ${testIds}\r\n${ex}\r\n\r\n`);
return Promise.reject(ex);
}

return deferred.promise;
Expand Down