Skip to content

Commit cbe837a

Browse files
Fix unit tests.
1 parent 1ec27ad commit cbe837a

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

src/test/common/terminals/synchronousTerminalService.unit.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ suite('Terminal Service (synchronous)', () => {
6767
});
6868
});
6969
suite('sendCommand', () => {
70+
const isolated = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'pyvsc-run-isolated.py');
7071
const shellExecFile = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'shell_exec.py');
7172

7273
test('run sendCommand in terminalService if there is no cancellation token', async () => {
@@ -107,6 +108,7 @@ suite('Terminal Service (synchronous)', () => {
107108
terminalService.sendCommand(
108109
'python',
109110
deepEqual([
111+
isolated.fileToCommandArgument(),
110112
shellExecFile.fileToCommandArgument(),
111113
'cmd'.fileToCommandArgument(),
112114
'1',
@@ -149,6 +151,7 @@ suite('Terminal Service (synchronous)', () => {
149151
terminalService.sendCommand(
150152
'python',
151153
deepEqual([
154+
isolated.fileToCommandArgument(),
152155
shellExecFile.fileToCommandArgument(),
153156
'cmd'.fileToCommandArgument(),
154157
'1',

src/test/interpreters/activation/service.unit.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,13 @@ suite('Interpreters Activation - Python Environment Variables', () => {
140140

141141
const shellCmd = capture(processService.shellExec).first()[0];
142142

143+
const isolated = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'pyvsc-run-isolated.py');
143144
const printEnvPyFile = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'printEnvVariables.py');
144-
const expectedCommand = `${cmd.join(
145-
' && '
146-
)} && echo '${getEnvironmentPrefix}' && python ${printEnvPyFile.fileToCommandArgument()}`;
145+
const expectedCommand = [
146+
...cmd,
147+
`echo '${getEnvironmentPrefix}'`,
148+
`python ${isolated} ${printEnvPyFile.fileToCommandArgument()}`
149+
].join(' && ');
147150

148151
expect(shellCmd).to.equal(expectedCommand);
149152
});

src/test/interpreters/activation/terminalEnvironmentActivationService.unit.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ suite('Interpreters Activation - Python Environment Variables (using terminals)'
9595
});
9696
test('Should execute python file in terminal (that is what dumps variables into json)', async () => {
9797
when(envVarsProvider.getCustomEnvironmentVariables(resource)).thenResolve(undefined);
98+
const isolated = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'pyvsc-run-isolated.py');
9899
const pyFile = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'printEnvVariablesToFile.py');
99100

100101
await envActivationService.getActivatedEnvironmentVariables(resource, interpreter);
@@ -103,7 +104,11 @@ suite('Interpreters Activation - Python Environment Variables (using terminals)'
103104
verify(
104105
terminal.sendCommand(
105106
cmd,
106-
deepEqual([pyFile.fileToCommandArgument(), jsonFile.fileToCommandArgument()]),
107+
deepEqual([
108+
isolated.fileToCommandArgument(),
109+
pyFile.fileToCommandArgument(),
110+
jsonFile.fileToCommandArgument()
111+
]),
107112
anything(),
108113
false
109114
)

src/test/testing/common/debugLauncher.unit.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ suite('Unit Tests - Debug Launcher', () => {
207207
expected = getDefaultDebugConfig();
208208
}
209209
expected.rules = [{ path: path.join(EXTENSION_ROOT_DIR, 'pythonFiles'), include: false }];
210-
expected.program = testLaunchScript;
211-
expected.args = options.args;
210+
expected.program = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'pyvsc-run-isolated.py');
211+
expected.args = [testLaunchScript, ...options.args];
212212
if (!expected.cwd) {
213213
expected.cwd = workspaceFolders[0].uri.fsPath;
214214
}

src/test/testing/navigation/symbolNavigator.unit.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ suite('Unit Tests - Navigation Command Handler', () => {
8686
});
8787
test('Ensure no symbols are returned when there are no symbols to be returned', async () => {
8888
const docUri = Uri.file(__filename);
89-
const args = [path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'symbolProvider.py'), docUri.fsPath];
89+
const args = [
90+
path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'pyvsc-run-isolated.py'),
91+
path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'symbolProvider.py'),
92+
docUri.fsPath
93+
];
9094
const proc: ExecutionResult<string> = {
9195
stdout: JSON.stringify({ classes: [], methods: [], functions: [] })
9296
};
@@ -114,7 +118,11 @@ suite('Unit Tests - Navigation Command Handler', () => {
114118
});
115119
test('Ensure symbols are returned', async () => {
116120
const docUri = Uri.file(__filename);
117-
const args = [path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'symbolProvider.py'), docUri.fsPath];
121+
const args = [
122+
path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'pyvsc-run-isolated.py'),
123+
path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'symbolProvider.py'),
124+
docUri.fsPath
125+
];
118126
const proc: ExecutionResult<string> = {
119127
stdout: JSON.stringify({
120128
classes: [

0 commit comments

Comments
 (0)