diff --git a/package.json b/package.json index 2f368f43..4239b168 100644 --- a/package.json +++ b/package.json @@ -327,6 +327,11 @@ "description": "Path (fully qualified) to the Python debug adapter executable.", "type": "string" }, + "autoStartBrowser": { + "default": false, + "description": "Open external browser to launch the application", + "type": "boolean" + }, "django": { "default": false, "description": "Django debugging.", diff --git a/src/extension/debugger/configuration/resolvers/base.ts b/src/extension/debugger/configuration/resolvers/base.ts index 78cfda80..7775ae0d 100644 --- a/src/extension/debugger/configuration/resolvers/base.ts +++ b/src/extension/debugger/configuration/resolvers/base.ts @@ -245,6 +245,7 @@ export abstract class BaseConfigurationResolver stopOnEntry: !!debugConfiguration.stopOnEntry, showReturnValue: !!debugConfiguration.showReturnValue, subProcess: !!debugConfiguration.subProcess, + autoStartBrowser: !!debugConfiguration, watson: name.toLowerCase().indexOf('watson') >= 0, pyspark: name.toLowerCase().indexOf('pyspark') >= 0, gevent: name.toLowerCase().indexOf('gevent') >= 0, diff --git a/src/extension/debugger/configuration/resolvers/launch.ts b/src/extension/debugger/configuration/resolvers/launch.ts index 5230637b..474ba04c 100644 --- a/src/extension/debugger/configuration/resolvers/launch.ts +++ b/src/extension/debugger/configuration/resolvers/launch.ts @@ -140,6 +140,13 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver { expect((debugConfig as DebugConfiguration).debugOptions).contains(DebugOptions.Jinja); }); + const testsForautoStartBrowser = [ + { + autoStartBrowser: true, + module: 'flask', + }, + { + autoStartBrowser: true, + django: true, + }, + ]; + + test('Add serverReadyAction for Django and Flask', async () => { + const pythonPath = `PythonPath_${new Date().toString()}`; + const workspaceFolder = createMoqWorkspaceFolder(__dirname); + const pythonFile = 'xyz.py'; + setupIoc(pythonPath); + setupActiveEditor(pythonFile, PYTHON_LANGUAGE); + const expectedServerReadyAction = { + pattern: '.*(https?:\\/\\/\\S+:[0-9]+\\/?).*', + uriFormat: '%s', + action: 'openExternally', + }; + testsForautoStartBrowser.forEach(async (testParams) => { + const debugConfig = await resolveDebugConfiguration(workspaceFolder, { + ...launch, + ...testParams, + }); + expect(debugConfig).to.have.property('serverReadyAction', expectedServerReadyAction); + }); + }); + async function testSetting( requestType: 'launch' | 'attach', settings: Record,