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

Fixed travis unit tests #1308

Merged
merged 66 commits into from
Oct 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d1da48b
update to use latest api
DonJayamanne Oct 3, 2017
15d8d35
Merge branch 'master' into 1228Multiroot
DonJayamanne Oct 4, 2017
b305a72
config changes for multiroot workspace
DonJayamanne Oct 5, 2017
674da9e
linting support with multi roots
DonJayamanne Oct 5, 2017
a549fc6
multi root support for formatters
DonJayamanne Oct 6, 2017
657e20f
determine workspace root path
DonJayamanne Oct 6, 2017
d492b5a
revert change
DonJayamanne Oct 6, 2017
c0c70fb
support multiple configs per workspace folder
DonJayamanne Oct 6, 2017
86e36c1
modify formatters to use resource specific settings
DonJayamanne Oct 6, 2017
c5cd8a9
modified installer to pass resource for workspace resolution
DonJayamanne Oct 9, 2017
663b345
null test in installer
DonJayamanne Oct 9, 2017
bcca381
canges to config settings to support multiroot workspace
DonJayamanne Oct 9, 2017
e3279cb
changes to code refactoring to support workspace symbols
DonJayamanne Oct 9, 2017
965eae9
oops
DonJayamanne Oct 9, 2017
234ff78
modified to settings are resolved using document uri
DonJayamanne Oct 9, 2017
e15e627
merged 1228Multiroot
DonJayamanne Oct 9, 2017
da4e2ab
unit tests for multi root support
DonJayamanne Oct 11, 2017
b575dcc
fix unittests for multiroot
DonJayamanne Oct 11, 2017
7457c89
exclude files
DonJayamanne Oct 11, 2017
54741c1
add new line
DonJayamanne Oct 11, 2017
ef306b0
config changes for multiroot workspace
DonJayamanne Oct 5, 2017
af113a4
installer, config changes with unit tests
DonJayamanne Oct 11, 2017
23ab751
new lines and enabled multi root linter tests
DonJayamanne Oct 11, 2017
b4295ef
fix sys variables
DonJayamanne Oct 12, 2017
360e919
added unit test to resolve ${workspaceRoot} in settings.json
DonJayamanne Oct 12, 2017
52e93c5
#1228 workspace symbols with multiroot support
DonJayamanne Oct 12, 2017
c2ba665
fix test
DonJayamanne Oct 12, 2017
e0f57ce
added some data for workspace symbol tests
DonJayamanne Oct 12, 2017
9e79d26
data for unit tests
DonJayamanne Oct 12, 2017
bbf2403
fixed to add support for multit roots with unit tests
DonJayamanne Oct 12, 2017
57ce355
account for mutiroot files in sub directory
DonJayamanne Oct 12, 2017
f044e27
disable all but multiroot tests
DonJayamanne Oct 12, 2017
99bf348
fixed tests
DonJayamanne Oct 12, 2017
45ac933
fix tests
DonJayamanne Oct 12, 2017
a2ba087
merged
DonJayamanne Oct 12, 2017
5a9a750
Merge branch '1228MultiRootMaster' into 1228FixTravisAndConfigSettings
DonJayamanne Oct 12, 2017
a819096
test where failing
DonJayamanne Oct 12, 2017
672d625
properly determine root workspace
DonJayamanne Oct 12, 2017
48ace91
fix pytest unit test
DonJayamanne Oct 12, 2017
61d7b8c
delete files
DonJayamanne Oct 12, 2017
fd812b7
Merge branch '1228MultiRootMaster' into 1228FixTravisAndConfigSettings
DonJayamanne Oct 12, 2017
fc10a55
add awaiter
DonJayamanne Oct 12, 2017
9ab5e14
use a path that works on multiple os
DonJayamanne Oct 12, 2017
fc66c9a
fixes
DonJayamanne Oct 13, 2017
121ff0f
uncomment
DonJayamanne Oct 13, 2017
6c01e78
invert
DonJayamanne Oct 13, 2017
b1b2677
debug statements
DonJayamanne Oct 13, 2017
76e4139
use default workspace
DonJayamanne Oct 13, 2017
35fba77
reverted unwanted changes
DonJayamanne Oct 13, 2017
22f0301
oops
DonJayamanne Oct 13, 2017
b9eaeaf
test unittests only
DonJayamanne Oct 13, 2017
1dd4cb4
more logging
DonJayamanne Oct 13, 2017
26a8fdc
partial fixes to unit tests
DonJayamanne Oct 13, 2017
75a9e7b
run all tests
DonJayamanne Oct 13, 2017
85c1085
changes not to set paths for shebang tests
DonJayamanne Oct 13, 2017
83e82e1
remove comments
DonJayamanne Oct 13, 2017
5101eb5
update settings only if necessary
DonJayamanne Oct 13, 2017
50e875c
fix test
DonJayamanne Oct 13, 2017
223b6dc
include files for tests
DonJayamanne Oct 13, 2017
67ec41e
Fixed travis tests for multi root workspace symbols (#1306)
DonJayamanne Oct 13, 2017
3da7274
merged
DonJayamanne Oct 13, 2017
158d837
merged fixes
DonJayamanne Oct 13, 2017
ee0003c
Added brackets around print statements (for p3)
DonJayamanne Oct 13, 2017
7a07dad
merged latest changes
DonJayamanne Oct 13, 2017
f4274c0
use resource when getting settings
DonJayamanne Oct 13, 2017
005f3f1
merged latest changes
DonJayamanne Oct 13, 2017
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ before_install: |
pyenv install $PYTHON
pyenv global $PYTHON
fi
export TRAVIS_PYTHON_PATH=`which python`
install:
- pip install --upgrade -r requirements.txt
- npm install
Expand Down
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"outFiles": [
"${workspaceRoot}/out/**/*.js"
],
"preLaunchTask": "npm"
"preLaunchTask": "compile"
},
{
"name": "Launch Extension as debugServer", // https://code.visualstudio.com/docs/extensions/example-debuggers
Expand Down Expand Up @@ -65,15 +65,15 @@
"outFiles": [
"${workspaceRoot}/out/**/*.js"
],
"preLaunchTask": "npm"
"preLaunchTask": "compile"
},
{
"name": "Launch Multiroot Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceRoot}/src/test/multiRootWkspc/multi.code-workspace",
"${workspaceRoot}/src/testMultiRootWkspc/multi.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test"
],
Expand Down
2 changes: 1 addition & 1 deletion src/client/debugger/configProviders/simpleProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class SimpleConfigurationProvider implements DebugConfigurationProvider {
type: 'python',
request: 'launch',
stopOnEntry: true,
pythonPath: PythonSettings.getInstance().pythonPath,
pythonPath: PythonSettings.getInstance(workspaceFolder ? Uri.file(workspaceFolder) : undefined).pythonPath,
program: defaultProgram,
cwd: workspaceFolder,
envFile,
Expand Down
2 changes: 1 addition & 1 deletion src/client/providers/execInTerminalProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function execInTerminal(fileUri?: vscode.Uri) {
const terminalShellSettings = vscode.workspace.getConfiguration('terminal.integrated.shell');
const IS_POWERSHELL = /powershell/.test(terminalShellSettings.get<string>('windows'));

let pythonSettings = settings.PythonSettings.getInstance();
let pythonSettings = settings.PythonSettings.getInstance(fileUri);
let filePath: string;

let currentPythonPath = pythonSettings.pythonPath;
Expand Down
2 changes: 1 addition & 1 deletion src/client/providers/shebangCodeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ShebangCodeLensProvider implements vscode.CodeLensProvider {

private async createShebangCodeLens(document: TextDocument) {
const shebang = await ShebangCodeLensProvider.detectShebang(document);
if (!shebang || shebang === settings.PythonSettings.getInstance().pythonPath) {
if (!shebang || shebang === settings.PythonSettings.getInstance(document.uri).pythonPath) {
return [];
}

Expand Down
5 changes: 4 additions & 1 deletion src/client/unittests/common/baseTestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as vscode from 'vscode';
import { resetTestResults, displayTestErrorMessage, storeDiscoveredTests } from './testUtils';
import { Installer, Product } from '../../common/installer';
import { isNotInstalledError } from '../../common/helpers';
import { IPythonSettings, PythonSettings } from '../../common/configSettings';

export abstract class BaseTestManager {
private tests: Tests;
Expand All @@ -25,9 +26,11 @@ export abstract class BaseTestManager {
this.cancellationTokenSource.cancel();
}
}
protected readonly settings: IPythonSettings;
constructor(private testProvider: string, private product: Product, protected rootDirectory: string, protected outputChannel: vscode.OutputChannel) {
this._status = TestStatus.Unknown;
this.installer = new Installer();
this.settings = PythonSettings.getInstance(vscode.Uri.file(this.rootDirectory));
}
public reset() {
this._status = TestStatus.Unknown;
Expand Down Expand Up @@ -179,4 +182,4 @@ export abstract class BaseTestManager {
});
}
abstract runTestImpl(tests: Tests, testsToRun?: TestsToRun, runFailedTests?: boolean, debug?: boolean): Promise<any>;
}
}
2 changes: 1 addition & 1 deletion src/client/unittests/common/debugLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { PythonSettings } from '../../common/configSettings';
import { execPythonFile } from './../../common/utils';
import { createDeferred } from './../../common/helpers';

const pythonSettings = PythonSettings.getInstance();
export function launchDebugger(rootDirectory: string, testArgs: string[], token?: CancellationToken, outChannel?: OutputChannel) {
const pythonSettings = PythonSettings.getInstance(rootDirectory ? Uri.file(rootDirectory) : undefined);
const def = createDeferred<any>();
const launchDef = createDeferred<any>();
let outputChannelShown = false;
Expand Down
10 changes: 6 additions & 4 deletions src/client/unittests/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import * as unittest from './unittest/testConfigurationManager';
import { getSubDirectories } from '../common/utils';
import * as path from 'path';

const settings = PythonSettings.getInstance();

function promptToEnableAndConfigureTestFramework(outputChannel: vscode.OutputChannel, messageToDisplay: string = 'Select a test framework/tool to enable', enableOnly: boolean = false): Thenable<any> {
const items = [{
label: 'unittest',
Expand Down Expand Up @@ -76,8 +74,9 @@ function promptToEnableAndConfigureTestFramework(outputChannel: vscode.OutputCha
// Cuz we don't want the test engine (in main.ts file - tests get discovered when config changes are detected)
// to start discovering tests when tests haven't been configured properly
function enableTest(): Thenable<any> {
// TODO: Enable multi workspace root support
const pythonConfig = vscode.workspace.getConfiguration('python');
if (settings.unitTest.promptToConfigure) {
if (pythonConfig.get('unitTest.promptToConfigure')) {
return configMgr.enable();
}
return pythonConfig.update('unitTest.promptToConfigure', undefined).then(() => {
Expand All @@ -94,6 +93,8 @@ function promptToEnableAndConfigureTestFramework(outputChannel: vscode.OutputCha
});
}
export function displayTestFrameworkError(outputChannel: vscode.OutputChannel): Thenable<any> {
// TODO: Enable multi workspace root support
const settings = PythonSettings.getInstance();
let enabledCount = settings.unitTest.pyTestEnabled ? 1 : 0;
enabledCount += settings.unitTest.nosetestsEnabled ? 1 : 0;
enabledCount += settings.unitTest.unittestEnabled ? 1 : 0;
Expand All @@ -111,6 +112,7 @@ export function displayTestFrameworkError(outputChannel: vscode.OutputChannel):
}
}
export function displayPromptToEnableTests(rootDir: string, outputChannel: vscode.OutputChannel): Thenable<any> {
const settings = PythonSettings.getInstance(vscode.Uri.file(rootDir));
if (settings.unitTest.pyTestEnabled ||
settings.unitTest.nosetestsEnabled ||
settings.unitTest.unittestEnabled) {
Expand Down Expand Up @@ -147,4 +149,4 @@ function checkIfHasTestDirs(rootDir: string): Promise<boolean> {
return getSubDirectories(rootDir).then(subDirs => {
return subDirs.map(dir => path.relative(rootDir, dir)).filter(dir => dir.match(/test/i)).length > 0;
});
}
}
15 changes: 11 additions & 4 deletions src/client/unittests/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ import {
} from './common/contracts';
import { resolveValueAsTestToRun, getDiscoveredTests } from './common/testUtils';
import { BaseTestManager } from './common/baseTestManager';
import { PythonSettings } from '../common/configSettings';
import { PythonSettings, IUnitTestSettings } from '../common/configSettings';
import { TestResultDisplay } from './display/main';
import { TestDisplay } from './display/picker';
import { activateCodeLenses } from './codeLenses/main';
import { displayTestFrameworkError } from './configuration';
import { PythonSymbolProvider } from '../providers/symbolProvider';

const settings = PythonSettings.getInstance();
let testManager: BaseTestManager | undefined | null;
let pyTestManager: pytest.TestManager | undefined | null;
let unittestManager: unittest.TestManager | undefined | null;
Expand All @@ -32,6 +31,9 @@ let outChannel: vscode.OutputChannel;
let onDidChange: vscode.EventEmitter<void> = new vscode.EventEmitter<void>();

export function activate(context: vscode.ExtensionContext, outputChannel: vscode.OutputChannel, symboldProvider: PythonSymbolProvider) {
// TODO: Add multi workspace support
const settings = PythonSettings.getInstance();
uniTestSettingsString = JSON.stringify(settings.unitTest);
context.subscriptions.push({ dispose: dispose });
outChannel = outputChannel;
let disposables = registerCommands();
Expand All @@ -51,6 +53,8 @@ export function activate(context: vscode.ExtensionContext, outputChannel: vscode
}

function getTestWorkingDirectory() {
// TODO: Add multi workspace support
const settings = PythonSettings.getInstance();
return settings.unitTest.cwd && settings.unitTest.cwd.length > 0 ? settings.unitTest.cwd : vscode.workspace.rootPath!;
}

Expand Down Expand Up @@ -184,9 +188,11 @@ function displayStopUI(message: string) {
testDisplay = testDisplay ? testDisplay : new TestDisplay();
testDisplay.displayStopTestUI(message);
}
let uniTestSettingsString = JSON.stringify(settings.unitTest);
let uniTestSettingsString: string;

function onConfigChanged() {
// TODO: Add multi workspace support
const settings = PythonSettings.getInstance();
// Possible that a test framework has been enabled or some settings have changed
// Meaning we need to re-load the discovered tests (as something could have changed)
const newSettings = JSON.stringify(settings.unitTest);
Expand Down Expand Up @@ -230,6 +236,7 @@ function onConfigChanged() {
}
function getTestRunner() {
const rootDirectory = getTestWorkingDirectory();
const settings = PythonSettings.getInstance(vscode.Uri.file(rootDirectory));
if (settings.unitTest.nosetestsEnabled) {
return nosetestManager = nosetestManager ? nosetestManager : new nosetests.TestManager(rootDirectory, outChannel);
}
Expand Down Expand Up @@ -317,4 +324,4 @@ function runTestsImpl(arg?: vscode.Uri | TestsToRun | boolean | FlattenedTestFun
});

testResultDisplay.DisplayProgressStatus(runPromise, debug);
}
}
5 changes: 2 additions & 3 deletions src/client/unittests/nosetest/collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import * as os from 'os';
import { extractBetweenDelimiters, convertFileToPackage, flattenTestFiles } from '../common/testUtils';
import { CancellationToken } from 'vscode';
import { PythonSettings } from '../../common/configSettings';
import { OutputChannel } from 'vscode';
import { OutputChannel, Uri } from 'vscode';

const pythonSettings = PythonSettings.getInstance();
const NOSE_WANT_FILE_PREFIX = 'nose.selector: DEBUG: wantFile ';
const NOSE_WANT_FILE_SUFFIX = '.py? True';
const NOSE_WANT_FILE_SUFFIX_WITHOUT_EXT = '? True';
Expand Down Expand Up @@ -78,7 +77,7 @@ export function discoverTests(rootDirectory: string, args: string[], token: Canc
});
}

return execPythonFile(pythonSettings.unitTest.nosetestPath, args.concat(['--collect-only', '-vvv']), rootDirectory, true)
return execPythonFile(PythonSettings.getInstance(Uri.file(rootDirectory)).unitTest.nosetestPath, args.concat(['--collect-only', '-vvv']), rootDirectory, true)
.then(data => {
outChannel.appendLine(data);
processOutput(data);
Expand Down
6 changes: 2 additions & 4 deletions src/client/unittests/nosetest/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import { BaseTestManager } from '../common/baseTestManager';
import { runTest } from './runner';
import { Product } from '../../common/installer';

const settings = PythonSettings.getInstance();

export class TestManager extends BaseTestManager {
constructor(rootDirectory: string, outputChannel: vscode.OutputChannel) {
super('nosetest', Product.nosetest, rootDirectory, outputChannel);
}
discoverTestsImpl(ignoreCache: boolean): Promise<Tests> {
let args = settings.unitTest.nosetestArgs.slice(0);
let args = this.settings.unitTest.nosetestArgs.slice(0);
return discoverTests(this.rootDirectory, args, this.cancellationToken, ignoreCache, this.outputChannel);
}
runTestImpl(tests: Tests, testsToRun?: TestsToRun, runFailedTests?: boolean, debug?: boolean): Promise<any> {
let args = settings.unitTest.nosetestArgs.slice(0);
let args = this.settings.unitTest.nosetestArgs.slice(0);
if (runFailedTests === true && args.indexOf('--failed') === -1) {
args.push('--failed');
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/unittests/nosetest/runner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
import { createTemporaryFile } from '../../common/helpers';
import { OutputChannel, CancellationToken } from 'vscode';
import { OutputChannel, CancellationToken, Uri } from 'vscode';
import { TestsToRun, Tests } from '../common/contracts';
import { updateResults } from '../common/testUtils';
import { updateResultsFromXmlLogFile, PassCalculationFormulae } from '../common/xUnitParser';
Expand All @@ -9,7 +9,6 @@ import { PythonSettings } from '../../common/configSettings';
import * as path from 'path';
import { launchDebugger } from '../common/debugLauncher';

const pythonSettings = PythonSettings.getInstance();
const WITH_XUNIT = '--with-xunit';
const XUNIT_FILE = '--xunit-file';

Expand Down Expand Up @@ -61,6 +60,7 @@ export function runTest(rootDirectory: string, tests: Tests, args: string[], tes
}

return promiseToGetXmlLogFile.then(() => {
const pythonSettings = PythonSettings.getInstance(Uri.file(rootDirectory));
if (debug === true) {
const testLauncherFile = path.join(__dirname, '..', '..', '..', '..', 'pythonFiles', 'PythonTools', 'testlauncher.py');
const nosetestlauncherargs = [rootDirectory, 'my_secret', pythonSettings.unitTest.debugPort.toString(), 'nose'];
Expand Down
4 changes: 1 addition & 3 deletions src/client/unittests/pytest/collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import * as path from 'path';
import { PythonSettings } from '../../common/configSettings';
import { OutputChannel } from 'vscode';

const pythonSettings = PythonSettings.getInstance();

const argsToExcludeForDiscovery = ['-x', '--exitfirst',
'--fixtures-per-test', '--pdb', '--runxfail',
'--lf', '--last-failed', '--ff', '--failed-first',
Expand Down Expand Up @@ -85,7 +83,7 @@ export function discoverTests(rootDirectory: string, args: string[], token: vsco
});
}

return execPythonFile(pythonSettings.unitTest.pyTestPath, args.concat(['--collect-only']), rootDirectory, false, null, token)
return execPythonFile(PythonSettings.getInstance(vscode.Uri.file(rootDirectory)).unitTest.pyTestPath, args.concat(['--collect-only']), rootDirectory, false, null, token)
.then(data => {
outChannel.appendLine(data);
processOutput(data);
Expand Down
6 changes: 2 additions & 4 deletions src/client/unittests/pytest/main.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
'use strict';
import { PythonSettings } from '../../common/configSettings';
import { TestsToRun, Tests } from '../common/contracts';
import { runTest } from './runner';
import * as vscode from 'vscode';
import { discoverTests } from './collector';
import { BaseTestManager } from '../common/baseTestManager';
import { Product } from '../../common/installer';

const settings = PythonSettings.getInstance();
export class TestManager extends BaseTestManager {
constructor(rootDirectory: string, outputChannel: vscode.OutputChannel) {
super('pytest', Product.pytest, rootDirectory, outputChannel);
}
discoverTestsImpl(ignoreCache: boolean): Promise<Tests> {
let args = settings.unitTest.pyTestArgs.slice(0);
let args = this.settings.unitTest.pyTestArgs.slice(0);
return discoverTests(this.rootDirectory, args, this.cancellationToken, ignoreCache, this.outputChannel);
}
runTestImpl(tests: Tests, testsToRun?: TestsToRun, runFailedTests?: boolean, debug?: boolean): Promise<any> {
let args = settings.unitTest.pyTestArgs.slice(0);
let args = this.settings.unitTest.pyTestArgs.slice(0);
if (runFailedTests === true && args.indexOf('--lf') === -1 && args.indexOf('--last-failed') === -1) {
args.push('--last-failed');
}
Expand Down
5 changes: 2 additions & 3 deletions src/client/unittests/pytest/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import { createTemporaryFile } from '../../common/helpers';
import { TestsToRun, Tests } from '../common/contracts';
import { updateResults } from '../common/testUtils';
import { CancellationToken, OutputChannel } from 'vscode';
import { CancellationToken, OutputChannel, Uri } from 'vscode';
import { updateResultsFromXmlLogFile, PassCalculationFormulae } from '../common/xUnitParser';
import { run } from '../common/runner';
import { PythonSettings } from '../../common/configSettings';
import * as path from 'path';
import { launchDebugger } from '../common/debugLauncher';

const pythonSettings = PythonSettings.getInstance();

export function runTest(rootDirectory: string, tests: Tests, args: string[], testsToRun?: TestsToRun, token?: CancellationToken, outChannel?: OutputChannel, debug?: boolean): Promise<Tests> {
let testPaths = [];
if (testsToRun && testsToRun.testFolder) {
Expand All @@ -39,6 +37,7 @@ export function runTest(rootDirectory: string, tests: Tests, args: string[], tes
args = args.filter(arg => arg.trim().startsWith('-'));
}
const testArgs = testPaths.concat(args, [`--junitxml=${xmlLogFile}`]);
const pythonSettings = PythonSettings.getInstance(Uri.file(rootDirectory));
if (debug) {
const testLauncherFile = path.join(__dirname, '..', '..', '..', '..', 'pythonFiles', 'PythonTools', 'testlauncher.py');
const pytestlauncherargs = [rootDirectory, 'my_secret', pythonSettings.unitTest.debugPort.toString(), 'pytest'];
Expand Down
6 changes: 2 additions & 4 deletions src/client/unittests/unittest/collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import * as path from 'path';
import { PythonSettings } from '../../common/configSettings';
import { OutputChannel } from 'vscode';

const pythonSettings = PythonSettings.getInstance();

export function discoverTests(rootDirectory: string, args: string[], token: vscode.CancellationToken, ignoreCache: boolean, outChannel: OutputChannel): Promise<Tests> {
let startDirectory = '.';
let pattern = 'test*.py';
Expand Down Expand Up @@ -73,7 +71,7 @@ for suite in suites._tests:
});
}
args = [];
return execPythonFile(pythonSettings.pythonPath, args.concat(['-c', pythonScript]), rootDirectory, true, null, token)
return execPythonFile(PythonSettings.getInstance(vscode.Uri.file(rootDirectory)).pythonPath, args.concat(['-c', pythonScript]), rootDirectory, true, null, token)
.then(data => {
outChannel.appendLine(data);
processOutput(data);
Expand Down Expand Up @@ -152,4 +150,4 @@ function addTestId(rootDirectory: string, testId: string, testFiles: TestFile[])
};

testSuite.functions.push(testFunction);
}
}
6 changes: 2 additions & 4 deletions src/client/unittests/unittest/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ import * as vscode from 'vscode';
import { discoverTests } from './collector';
import { BaseTestManager } from '../common/baseTestManager';
import { Product } from '../../common/installer';

const settings = PythonSettings.getInstance();
export class TestManager extends BaseTestManager {
constructor(rootDirectory: string, outputChannel: vscode.OutputChannel) {
super('unitest', Product.unittest, rootDirectory, outputChannel);
}
configure() {
}
discoverTestsImpl(ignoreCache: boolean): Promise<Tests> {
let args = settings.unitTest.unittestArgs.slice(0);
let args = this.settings.unitTest.unittestArgs.slice(0);
return discoverTests(this.rootDirectory, args, this.cancellationToken, ignoreCache, this.outputChannel);
}
runTestImpl(tests: Tests, testsToRun?: TestsToRun, runFailedTests?: boolean, debug?: boolean): Promise<any> {
let args = settings.unitTest.unittestArgs.slice(0);
let args = this.settings.unitTest.unittestArgs.slice(0);
if (runFailedTests === true) {
testsToRun = { testFile: [], testFolder: [], testSuite: [], testFunction: [] };
testsToRun.testFunction = tests.testFunctions.filter(fn => {
Expand Down
Loading