Skip to content

Commit aff0b05

Browse files
Use python debugger in testing (microsoft#22903)
closed: microsoft/vscode-python-debugger#174
1 parent 84734a8 commit aff0b05

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

src/client/debugger/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
'use strict';
55

66
export const DebuggerTypeName = 'python';
7+
export const PythonDebuggerTypeName = 'debugpy';

src/client/debugger/types.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { DebugConfiguration } from 'vscode';
77
import { DebugProtocol } from 'vscode-debugprotocol/lib/debugProtocol';
8-
import { DebuggerTypeName } from './constants';
8+
import { DebuggerTypeName, PythonDebuggerTypeName } from './constants';
99

1010
export enum DebugOptions {
1111
RedirectOutput = 'RedirectOutput',
@@ -123,14 +123,14 @@ export interface LaunchRequestArguments
123123
extends DebugProtocol.LaunchRequestArguments,
124124
IKnownLaunchRequestArguments,
125125
DebugConfiguration {
126-
type: typeof DebuggerTypeName;
126+
type: typeof DebuggerTypeName | typeof PythonDebuggerTypeName;
127127
}
128128

129129
export interface AttachRequestArguments
130130
extends DebugProtocol.AttachRequestArguments,
131131
IKnownAttachDebugArguments,
132132
DebugConfiguration {
133-
type: typeof DebuggerTypeName;
133+
type: typeof DebuggerTypeName | typeof PythonDebuggerTypeName;
134134
}
135135

136136
export interface DebugConfigurationArguments extends LaunchRequestArguments, AttachRequestArguments {}

src/client/testing/common/debugLauncher.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { IApplicationShell, IDebugService } from '../../common/application/types
55
import { EXTENSION_ROOT_DIR } from '../../common/constants';
66
import * as internalScripts from '../../common/process/internal/scripts';
77
import { IConfigurationService, IPythonSettings } from '../../common/types';
8-
import { DebuggerTypeName } from '../../debugger/constants';
8+
import { DebuggerTypeName, PythonDebuggerTypeName } from '../../debugger/constants';
99
import { IDebugConfigurationResolver } from '../../debugger/extension/configuration/types';
1010
import { DebugPurpose, LaunchRequestArguments } from '../../debugger/types';
1111
import { IServiceContainer } from '../../ioc/types';
@@ -78,7 +78,7 @@ export class DebugLauncher implements ITestDebugLauncher {
7878
if (!debugConfig) {
7979
debugConfig = {
8080
name: 'Debug Unit Test',
81-
type: 'python',
81+
type: 'debugpy',
8282
request: 'test',
8383
subProcess: true,
8484
};
@@ -118,7 +118,7 @@ export class DebugLauncher implements ITestDebugLauncher {
118118
for (const cfg of configs) {
119119
if (
120120
cfg.name &&
121-
cfg.type === DebuggerTypeName &&
121+
(cfg.type === DebuggerTypeName || cfg.type === PythonDebuggerTypeName) &&
122122
(cfg.request === 'test' ||
123123
(cfg as LaunchRequestArguments).purpose?.includes(DebugPurpose.DebugTest))
124124
) {

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

+21-21
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { IApplicationShell, IDebugService } from '../../../client/common/applica
1616
import { EXTENSION_ROOT_DIR } from '../../../client/common/constants';
1717
import '../../../client/common/extensions';
1818
import { IConfigurationService, IPythonSettings } from '../../../client/common/types';
19-
import { DebuggerTypeName } from '../../../client/debugger/constants';
19+
import { PythonDebuggerTypeName } from '../../../client/debugger/constants';
2020
import { IDebugEnvironmentVariablesService } from '../../../client/debugger/extension/configuration/resolvers/helper';
2121
import { LaunchConfigurationResolver } from '../../../client/debugger/extension/configuration/resolvers/launch';
2222
import { DebugOptions } from '../../../client/debugger/types';
@@ -166,7 +166,7 @@ suite('Unit Tests - Debug Launcher', () => {
166166
function getDefaultDebugConfig(): DebugConfiguration {
167167
return {
168168
name: 'Debug Unit Test',
169-
type: DebuggerTypeName,
169+
type: PythonDebuggerTypeName,
170170
request: 'launch',
171171
console: 'internalConsole',
172172
env: {},
@@ -329,7 +329,7 @@ suite('Unit Tests - Debug Launcher', () => {
329329
};
330330
const expected = getDefaultDebugConfig();
331331
expected.name = 'spam';
332-
setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: DebuggerTypeName, request: 'test' }]);
332+
setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: PythonDebuggerTypeName, request: 'test' }]);
333333

334334
await debugLauncher.launchDebugger(options);
335335

@@ -363,7 +363,7 @@ suite('Unit Tests - Debug Launcher', () => {
363363
};
364364
const expected = {
365365
name: 'my tests',
366-
type: DebuggerTypeName,
366+
type: PythonDebuggerTypeName,
367367
request: 'launch',
368368
python: 'some/dir/bin/py3',
369369
debugAdapterPython: 'some/dir/bin/py3',
@@ -388,7 +388,7 @@ suite('Unit Tests - Debug Launcher', () => {
388388
setupSuccess(options, 'unittest', expected, [
389389
{
390390
name: 'my tests',
391-
type: DebuggerTypeName,
391+
type: PythonDebuggerTypeName,
392392
request: 'test',
393393
pythonPath: expected.python,
394394
stopOnEntry: expected.stopOnEntry,
@@ -417,9 +417,9 @@ suite('Unit Tests - Debug Launcher', () => {
417417
const expected = getDefaultDebugConfig();
418418
expected.name = 'spam1';
419419
setupSuccess(options, 'unittest', expected, [
420-
{ name: 'spam1', type: DebuggerTypeName, request: 'test' },
421-
{ name: 'spam2', type: DebuggerTypeName, request: 'test' },
422-
{ name: 'spam3', type: DebuggerTypeName, request: 'test' },
420+
{ name: 'spam1', type: PythonDebuggerTypeName, request: 'test' },
421+
{ name: 'spam2', type: PythonDebuggerTypeName, request: 'test' },
422+
{ name: 'spam3', type: PythonDebuggerTypeName, request: 'test' },
423423
]);
424424

425425
await debugLauncher.launchDebugger(options);
@@ -446,15 +446,15 @@ suite('Unit Tests - Debug Launcher', () => {
446446
'// test 2 \n\
447447
{ \n\
448448
"name": "spam", \n\
449-
"type": "python", \n\
449+
"type": "debugpy", \n\
450450
"request": "test" \n\
451451
} \n\
452452
',
453453
'// test 3 \n\
454454
[ \n\
455455
{ \n\
456456
"name": "spam", \n\
457-
"type": "python", \n\
457+
"type": "debugpy", \n\
458458
"request": "test" \n\
459459
} \n\
460460
] \n\
@@ -464,7 +464,7 @@ suite('Unit Tests - Debug Launcher', () => {
464464
"configurations": [ \n\
465465
{ \n\
466466
"name": "spam", \n\
467-
"type": "python", \n\
467+
"type": "debugpy", \n\
468468
"request": "test" \n\
469469
} \n\
470470
] \n\
@@ -499,10 +499,10 @@ suite('Unit Tests - Debug Launcher', () => {
499499
setupSuccess(options, 'unittest', expected, [
500500
{} as DebugConfiguration,
501501
{ name: 'spam1' } as DebugConfiguration,
502-
{ name: 'spam2', type: DebuggerTypeName } as DebugConfiguration,
502+
{ name: 'spam2', type: PythonDebuggerTypeName } as DebugConfiguration,
503503
{ name: 'spam3', request: 'test' } as DebugConfiguration,
504-
{ type: DebuggerTypeName } as DebugConfiguration,
505-
{ type: DebuggerTypeName, request: 'test' } as DebugConfiguration,
504+
{ type: PythonDebuggerTypeName } as DebugConfiguration,
505+
{ type: PythonDebuggerTypeName, request: 'test' } as DebugConfiguration,
506506
{ request: 'test' } as DebugConfiguration,
507507
]);
508508

@@ -532,7 +532,7 @@ suite('Unit Tests - Debug Launcher', () => {
532532
testProvider: 'unittest',
533533
};
534534
const expected = getDefaultDebugConfig();
535-
setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: DebuggerTypeName, request: 'bogus' }]);
535+
setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: PythonDebuggerTypeName, request: 'bogus' }]);
536536

537537
await debugLauncher.launchDebugger(options);
538538

@@ -547,8 +547,8 @@ suite('Unit Tests - Debug Launcher', () => {
547547
};
548548
const expected = getDefaultDebugConfig();
549549
setupSuccess(options, 'unittest', expected, [
550-
{ name: 'spam', type: DebuggerTypeName, request: 'launch' },
551-
{ name: 'spam', type: DebuggerTypeName, request: 'attach' },
550+
{ name: 'spam', type: PythonDebuggerTypeName, request: 'launch' },
551+
{ name: 'spam', type: PythonDebuggerTypeName, request: 'attach' },
552552
]);
553553

554554
await debugLauncher.launchDebugger(options);
@@ -567,9 +567,9 @@ suite('Unit Tests - Debug Launcher', () => {
567567
setupSuccess(options, 'unittest', expected, [
568568
{ name: 'foo1', type: 'other', request: 'bar' },
569569
{ name: 'foo2', type: 'other', request: 'bar' },
570-
{ name: 'spam1', type: DebuggerTypeName, request: 'launch' },
571-
{ name: 'spam2', type: DebuggerTypeName, request: 'test' },
572-
{ name: 'spam3', type: DebuggerTypeName, request: 'attach' },
570+
{ name: 'spam1', type: PythonDebuggerTypeName, request: 'launch' },
571+
{ name: 'spam2', type: PythonDebuggerTypeName, request: 'test' },
572+
{ name: 'spam3', type: PythonDebuggerTypeName, request: 'attach' },
573573
{ name: 'xyz', type: 'another', request: 'abc' },
574574
]);
575575

@@ -599,7 +599,7 @@ suite('Unit Tests - Debug Launcher', () => {
599599
{ \n\
600600
// "test" debug config \n\
601601
"name": "spam", /* non-empty */ \n\
602-
"type": "python", /* must be "python" */ \n\
602+
"type": "debugpy", /* must be "python" */ \n\
603603
"request": "test", /* must be "test" */ \n\
604604
// extra stuff here: \n\
605605
"stopOnEntry": true \n\

0 commit comments

Comments
 (0)