Skip to content

Commit 10ca82b

Browse files
committed
Fix tests
1 parent c7e952a commit 10ca82b

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

src/client/debugger/configProviders/pythonV2Provider.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,53 +19,53 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
1919
super.provideLaunchDefaults(workspaceFolder, debugConfiguration);
2020
const debugOptions = debugConfiguration.debugOptions!;
2121
if (debugConfiguration.debugStdLib) {
22-
debugOptions.push(DebugOptions.DebugStdLib);
22+
this.debugOption(debugOptions, DebugOptions.DebugStdLib);
2323
}
2424
if (debugConfiguration.django) {
25-
debugOptions.push(DebugOptions.Django);
25+
this.debugOption(debugOptions, DebugOptions.Django);
2626
}
2727
if (debugConfiguration.jinja) {
28-
debugOptions.push(DebugOptions.Jinja);
28+
this.debugOption(debugOptions, DebugOptions.Jinja);
2929
}
3030
if (debugConfiguration.redirectOutput || debugConfiguration.redirectOutput === undefined) {
31-
debugOptions.push(DebugOptions.RedirectOutput);
31+
this.debugOption(debugOptions, DebugOptions.RedirectOutput);
3232
}
3333
if (debugConfiguration.sudo) {
34-
debugOptions.push(DebugOptions.Sudo);
34+
this.debugOption(debugOptions, DebugOptions.Sudo);
3535
}
3636
if (this.serviceContainer.get<IPlatformService>(IPlatformService).isWindows) {
37-
debugOptions.push(DebugOptions.FixFilePathCase);
37+
this.debugOption(debugOptions, DebugOptions.FixFilePathCase);
3838
}
3939
if (debugConfiguration.module && debugConfiguration.module.toUpperCase() === 'FLASK'
4040
&& debugOptions.indexOf(DebugOptions.Jinja) === -1
4141
&& debugConfiguration.jinja !== false) {
42-
debugOptions.push(DebugOptions.Jinja);
42+
this.debugOption(debugOptions, DebugOptions.Jinja);
4343
}
4444
}
4545
protected provideAttachDefaults(workspaceFolder: Uri, debugConfiguration: PythonAttachDebugConfiguration<AttachRequestArguments>): void {
4646
super.provideAttachDefaults(workspaceFolder, debugConfiguration);
4747
const debugOptions = debugConfiguration.debugOptions!;
4848
if (debugConfiguration.debugStdLib) {
49-
debugOptions.push(DebugOptions.DebugStdLib);
49+
this.debugOption(debugOptions, DebugOptions.DebugStdLib);
5050
}
5151
if (debugConfiguration.django) {
52-
debugOptions.push(DebugOptions.Django);
52+
this.debugOption(debugOptions, DebugOptions.Django);
5353
}
5454
if (debugConfiguration.jinja) {
55-
debugOptions.push(DebugOptions.Jinja);
55+
this.debugOption(debugOptions, DebugOptions.Jinja);
5656
}
5757
if (debugConfiguration.redirectOutput || debugConfiguration.redirectOutput === undefined) {
58-
debugOptions.push(DebugOptions.RedirectOutput);
58+
this.debugOption(debugOptions, DebugOptions.RedirectOutput);
5959
}
6060

6161
// We'll need paths to be fixed only in the case where local and remote hosts are the same
6262
// I.e. only if hostName === 'localhost' or '127.0.0.1' or ''
6363
const isLocalHost = !debugConfiguration.host || debugConfiguration.host === 'localhost' || debugConfiguration.host === '127.0.0.1';
6464
if (this.serviceContainer.get<IPlatformService>(IPlatformService).isWindows && isLocalHost) {
65-
debugOptions.push(DebugOptions.FixFilePathCase);
65+
this.debugOption(debugOptions, DebugOptions.FixFilePathCase);
6666
}
6767
if (this.serviceContainer.get<IPlatformService>(IPlatformService).isWindows) {
68-
debugOptions.push(DebugOptions.WindowsClient);
68+
this.debugOption(debugOptions, DebugOptions.WindowsClient);
6969
}
7070

7171
if (!debugConfiguration.pathMappings) {
@@ -78,4 +78,10 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
7878
});
7979
}
8080
}
81+
private debugOption(debugOptions: DebugOptions[], debugOption: DebugOptions) {
82+
if (debugOptions.indexOf(debugOption) >= 0) {
83+
return;
84+
}
85+
debugOptions.push(debugOption);
86+
}
8187
}

src/test/debugger/configProvider/provider.attach.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,10 @@ enum OS {
234234
setupWorkspaces([defaultWorkspace]);
235235

236236
const debugOptions = debugOptionsAvailable.slice().concat(DebugOptions.Jinja, DebugOptions.Sudo);
237+
const expectedDebugOptions = debugOptions.slice();
237238
const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, { debugOptions, request: 'attach' } as any as DebugConfiguration);
238239

239-
expect(debugConfig).to.have.property('debugOptions').to.be.deep.equal(debugOptions);
240+
expect(debugConfig).to.have.property('debugOptions').to.be.deep.equal(expectedDebugOptions);
240241
});
241242
});
242243
});

0 commit comments

Comments
 (0)