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
12 changes: 7 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/datascience-ui/interactive-common/mainState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,14 @@ export function generateCells(filePath: string, repetitions: number): ICell[] {
for (let i = 0; i < repetitions; i += 1) {
cellData = [...cellData, ...generateCellData()];
}
// Dynamically require vscode, this is testing code.
// Obfuscate the import to prevent webpack from picking this up.
// tslint:disable-next-line: no-eval (webpack is smart enough to look for `require` and `eval`).
const Uri = eval('req' + 'uire')('vscode').Uri;
return cellData.map((data: nbformat.ICodeCell | nbformat.IMarkdownCell | nbformat.IRawCell | IMessageCell, key: number) => {
return {
id: key.toString(),
file: path.join(filePath, 'foo.py'),
file: Uri.file(path.join(filePath, 'foo.py')).fsPath,
line: 1,
state: key === cellData.length - 1 ? CellState.executing : CellState.finished,
type: key === 3 ? 'preview' : 'execute',
Expand Down
2 changes: 1 addition & 1 deletion src/test/activation/activationService.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ suite('Activation - ActivationService', () => {
resource: Resource
) {
activator
.setup(a => a.activate(resource))
.setup(a => a.activate(TypeMoq.It.isValue(resource)))
.returns(() => Promise.resolve())
.verifiable(TypeMoq.Times.once());
lsNotSupportedDiagnosticService
Expand Down
10 changes: 5 additions & 5 deletions src/test/datascience/datascience.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ suite('Data Science Tests', () => {

assert.equal(expandWorkingDir(undefined, 'bar/foo.baz', inst), 'bar');
assert.equal(expandWorkingDir(undefined, 'bar/bip/foo.baz', inst), 'bar/bip');
assert.equal(expandWorkingDir('${file}', 'bar/bip/foo.baz', inst), 'bar/bip/foo.baz');
assert.equal(expandWorkingDir('${fileDirname}', 'bar/bip/foo.baz', inst), 'bar/bip');
assert.equal(expandWorkingDir('${file}', 'bar/bip/foo.baz', inst), Uri.file('bar/bip/foo.baz').fsPath);
assert.equal(expandWorkingDir('${fileDirname}', 'bar/bip/foo.baz', inst), Uri.file('bar/bip').fsPath);
assert.equal(expandWorkingDir('${relativeFile}', 'test/xyz/bip/foo.baz', inst), relativeFilePath);
assert.equal(expandWorkingDir('${relativeFileDirname}', 'test/xyz/bip/foo.baz', inst), relativeFileDir);
assert.equal(expandWorkingDir('${cwd}', 'test/xyz/bip/foo.baz', inst), 'test/bar');
assert.equal(expandWorkingDir('${workspaceFolder}', 'test/xyz/bip/foo.baz', inst), 'test/bar');
assert.equal(expandWorkingDir('${cwd}-${file}', 'bar/bip/foo.baz', inst), 'test/bar-bar/bip/foo.baz');
assert.equal(expandWorkingDir('${cwd}', 'test/xyz/bip/foo.baz', inst), Uri.file('test/bar').fsPath);
assert.equal(expandWorkingDir('${workspaceFolder}', 'test/xyz/bip/foo.baz', inst), Uri.file('test/bar').fsPath);
assert.equal(expandWorkingDir('${cwd}-${file}', 'bar/bip/foo.baz', inst), `${Uri.file('test/bar').fsPath}-${Uri.file('bar/bip/foo.baz').fsPath}`);
});

test('input history', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use strict';
import { assert } from 'chai';
import * as TypeMoq from 'typemoq';
import { Position, Range } from 'vscode';
import { Position, Range, Uri } from 'vscode';

import { IDebugService } from '../../../client/common/application/types';
import { IConfigurationService, IDataScienceSettings, IPythonSettings } from '../../../client/common/types';
Expand Down Expand Up @@ -52,7 +52,7 @@ suite('CellHashProvider Unit Tests', () => {

function sendCode(code: string, line: number, file?: string): Promise<void> {
const cell: ICell = {
file: file ? file : 'foo.py',
file: Uri.file(file ? file : 'foo.py').fsPath,
line,
data: {
source: code,
Expand Down Expand Up @@ -279,8 +279,8 @@ suite('CellHashProvider Unit Tests', () => {
// Execution count should go up, but still only have two cells.
const hashes = hashProvider.getHashes();
assert.equal(hashes.length, 2, 'Wrong number of hashes');
const fooHash = hashes.find(h => h.file === 'foo.py');
const barHash = hashes.find(h => h.file === 'bar.py');
const fooHash = hashes.find(h => h.file === Uri.file('foo.py').fsPath);
const barHash = hashes.find(h => h.file === Uri.file('bar.py').fsPath);
assert.ok(fooHash, 'No hash for foo.py');
assert.ok(barHash, 'No hash for bar.py');
assert.equal(fooHash!.hashes.length, 2, 'Not enough hashes found');
Expand Down
52 changes: 26 additions & 26 deletions src/test/datascience/editor-integration/codewatcher.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Disable whitespace / multiline as we use that to pass in our fake file strings
import { expect } from 'chai';
import * as TypeMoq from 'typemoq';
import { CancellationTokenSource, CodeLens, Disposable, Range, Selection, TextEditor } from 'vscode';
import { CancellationTokenSource, CodeLens, Disposable, Range, Selection, TextEditor, Uri } from 'vscode';

import { ICommandManager, IDebugService, IDocumentManager } from '../../../client/common/application/types';
import { PythonSettings } from '../../../client/common/configSettings';
Expand Down Expand Up @@ -176,7 +176,7 @@ suite('DataScience Code Watcher Unit Tests', () => {
}

test('Add a file with just a #%% mark to a code watcher', () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText = `#%%`;
const document = createDocument(inputText, fileName, version, TypeMoq.Times.atLeastOnce());
Expand All @@ -197,7 +197,7 @@ suite('DataScience Code Watcher Unit Tests', () => {
});

test('Add a file without a mark to a code watcher', () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText = `dummy`;
const document = createDocument(inputText, fileName, version, TypeMoq.Times.atLeastOnce());
Expand All @@ -217,7 +217,7 @@ suite('DataScience Code Watcher Unit Tests', () => {
});

test('Add a file with multiple marks to a code watcher', () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`first line
Expand Down Expand Up @@ -248,7 +248,7 @@ fourth line`;
});

test('Add a file with custom marks to a code watcher', () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`first line
Expand Down Expand Up @@ -286,7 +286,7 @@ fourth line
});

test('Make sure invalid regex from a user still work', () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`first line
Expand Down Expand Up @@ -324,7 +324,7 @@ fourth line
});

test('Test the RunCell command', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const testString = '#%%\ntesting';
const document = createDocument(testString, fileName, version, TypeMoq.Times.atLeastOnce(), true);
Expand All @@ -350,7 +350,7 @@ fourth line
});

test('Test the RunFileInteractive command', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand All @@ -364,7 +364,7 @@ testing2`; // Command tests override getText, so just need the ranges here
// Set up our expected calls to add code
// RunFileInteractive should run the entire file in one block, not cell by cell like RunAllCells
activeInteractiveWindow.setup(h => h.addCode(TypeMoq.It.isValue(inputText),
TypeMoq.It.isValue('test.py'),
TypeMoq.It.isValue(fileName),
TypeMoq.It.isValue(0),
TypeMoq.It.isAny(),
TypeMoq.It.isAny()
Expand All @@ -378,7 +378,7 @@ testing2`; // Command tests override getText, so just need the ranges here
});

test('Test the RunAllCells command', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand All @@ -399,14 +399,14 @@ testing2`; // Command tests override getText, so just need the ranges here

// Set up our expected calls to add code
activeInteractiveWindow.setup(h => h.addCode(TypeMoq.It.isValue(testString1),
TypeMoq.It.isValue('test.py'),
TypeMoq.It.isValue(fileName),
TypeMoq.It.isValue(0),
TypeMoq.It.isAny(),
TypeMoq.It.isAny()
)).returns(() => Promise.resolve(true)).verifiable(TypeMoq.Times.once());

activeInteractiveWindow.setup(h => h.addCode(TypeMoq.It.isValue(testString2),
TypeMoq.It.isValue('test.py'),
TypeMoq.It.isValue(fileName),
TypeMoq.It.isValue(2),
TypeMoq.It.isAny(),
TypeMoq.It.isAny()
Expand All @@ -420,7 +420,7 @@ testing2`; // Command tests override getText, so just need the ranges here
});

test('Test the RunCurrentCell command', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand Down Expand Up @@ -453,7 +453,7 @@ testing2`;
});

test('Test the RunCellAndAllBelow command', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand Down Expand Up @@ -497,7 +497,7 @@ testing3`;
});

test('Test the RunAllCellsAbove command', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand Down Expand Up @@ -541,7 +541,7 @@ testing2`;
});

test('Test the RunToLine command', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand Down Expand Up @@ -574,7 +574,7 @@ testing1`;
});

test('Test the RunToLine command with nothing on the lines', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`
Expand Down Expand Up @@ -603,7 +603,7 @@ print('testing')`;
});

test('Test the RunFromLine command', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand Down Expand Up @@ -639,7 +639,7 @@ testing3`;
});

test('Test the RunSelection command', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand Down Expand Up @@ -677,7 +677,7 @@ testing2`;
});

test('Test the RunCellAndAdvance command with next cell', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand All @@ -693,7 +693,7 @@ testing2`; // Command tests override getText, so just need the ranges here

// Set up our expected calls to add code
activeInteractiveWindow.setup(h => h.addCode(TypeMoq.It.isValue(testString),
TypeMoq.It.isValue('test.py'),
TypeMoq.It.isValue(fileName),
TypeMoq.It.isValue(0),
TypeMoq.It.is((ed: TextEditor) => {
return textEditor.object === ed;
Expand Down Expand Up @@ -732,7 +732,7 @@ testing2`; // Command tests override getText, so just need the ranges here

test('CodeLens returned after settings changed is different', () => {
// Create our document
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText = '#%% foobar';
const document = createDocument(inputText, fileName, version, TypeMoq.Times.atLeastOnce());
Expand Down Expand Up @@ -764,7 +764,7 @@ testing2`; // Command tests override getText, so just need the ranges here
});

test('Test the RunAllCellsAbove command with an error', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand Down Expand Up @@ -808,7 +808,7 @@ testing2`;
});

test('Test the RunAllCells command with an error', async () => {
const fileName = 'test.py';
const fileName = Uri.file('test.py').fsPath;
const version = 1;
const inputText =
`#%%
Expand All @@ -829,14 +829,14 @@ testing2`; // Command tests override getText, so just need the ranges here

// Set up our expected calls to add code
activeInteractiveWindow.setup(h => h.addCode(TypeMoq.It.isValue(testString1),
TypeMoq.It.isValue('test.py'),
TypeMoq.It.isValue(fileName),
TypeMoq.It.isValue(0),
TypeMoq.It.isAny(),
TypeMoq.It.isAny()
)).returns(() => Promise.resolve(false)).verifiable(TypeMoq.Times.once());

activeInteractiveWindow.setup(h => h.addCode(TypeMoq.It.isValue(testString2),
TypeMoq.It.isValue('test.py'),
TypeMoq.It.isValue(fileName),
TypeMoq.It.isValue(2),
TypeMoq.It.isAny(),
TypeMoq.It.isAny()
Expand Down
4 changes: 2 additions & 2 deletions src/test/datascience/editor-integration/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.
'use strict';
import * as TypeMoq from 'typemoq';
import { Range, TextDocument, TextLine } from 'vscode';
import { Range, TextDocument, TextLine, Uri } from 'vscode';

// tslint:disable:max-func-body-length no-trailing-whitespace no-multiline-string
// Disable whitespace / multiline as we use that to pass in our fake file strings
Expand All @@ -18,7 +18,7 @@ export function createDocument(inputText: string, fileName: string, fileVersion:
document.setup(d => d.languageId).returns(() => 'python');

// First set the metadata
document.setup(d => d.fileName).returns(() => fileName).verifiable(times);
document.setup(d => d.fileName).returns(() => Uri.file(fileName).fsPath).verifiable(times);
document.setup(d => d.version).returns(() => fileVersion).verifiable(times);

// Next add the lines in
Expand Down
3 changes: 2 additions & 1 deletion src/test/datascience/intellisense.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { expect } from 'chai';
import * as monacoEditor from 'monaco-editor/esm/vs/editor/editor.api';
import * as TypeMoq from 'typemoq';

import { Uri } from 'vscode';
import { ILanguageServer, ILanguageServerAnalysisOptions } from '../../client/activation/types';
import { IWorkspaceService } from '../../client/common/application/types';
import { PythonSettings } from '../../client/common/configSettings';
Expand Down Expand Up @@ -96,7 +97,7 @@ suite('DataScience Intellisense Unit Tests', () => {
}

function addCell(code: string, id: string): Promise<void> {
return sendMessage(InteractiveWindowMessages.AddCell, { fullText: code, currentText: code, file: 'foo.py', id });
return sendMessage(InteractiveWindowMessages.AddCell, { fullText: code, currentText: code, file: Uri.file('foo.py').fsPath, id });
}

function updateCell(newCode: string, oldCode: string, id: string): Promise<void> {
Expand Down
Loading