From 4464201558785a43b84679417241ca55266874fc Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 26 Apr 2018 15:14:12 -0700 Subject: [PATCH] Enable jinja template debugging when debugging pyramid apps --- news/1 Enhancements/1492.md | 1 + package.json | 3 ++- src/client/debugger/configProviders/pythonV2Provider.ts | 8 +++++++- src/test/debugger/configProvider/provider.test.ts | 9 +++++++-- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 news/1 Enhancements/1492.md diff --git a/news/1 Enhancements/1492.md b/news/1 Enhancements/1492.md new file mode 100644 index 000000000000..fe8decf90818 --- /dev/null +++ b/news/1 Enhancements/1492.md @@ -0,0 +1 @@ +Enable Jinja template debugging as a default behavior when debugging Pyramid applications. diff --git a/package.json b/package.json index 7abba1b72240..6dfa0b0a8c3b 100644 --- a/package.json +++ b/package.json @@ -871,7 +871,8 @@ "args": [ "^\"\\${workspaceFolder}/development.ini\"" ], - "pyramid": true + "pyramid": true, + "jinja": true } }, { diff --git a/src/client/debugger/configProviders/pythonV2Provider.ts b/src/client/debugger/configProviders/pythonV2Provider.ts index 4b60be89a688..89ac776dddd4 100644 --- a/src/client/debugger/configProviders/pythonV2Provider.ts +++ b/src/client/debugger/configProviders/pythonV2Provider.ts @@ -37,7 +37,8 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide if (this.serviceContainer.get(IPlatformService).isWindows) { this.debugOption(debugOptions, DebugOptions.FixFilePathCase); } - if (debugConfiguration.module && debugConfiguration.module.toUpperCase() === 'FLASK' + const isFlask = debugConfiguration.module && debugConfiguration.module.toUpperCase() === 'FLASK'; + if ((debugConfiguration.pyramid || isFlask) && debugOptions.indexOf(DebugOptions.Jinja) === -1 && debugConfiguration.jinja !== false) { this.debugOption(debugOptions, DebugOptions.Jinja); @@ -59,6 +60,11 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide if (debugConfiguration.jinja) { this.debugOption(debugOptions, DebugOptions.Jinja); } + if (debugConfiguration.pyramid + && debugOptions.indexOf(DebugOptions.Jinja) === -1 + && debugConfiguration.jinja !== false) { + this.debugOption(debugOptions, DebugOptions.Jinja); + } if (debugConfiguration.redirectOutput || debugConfiguration.redirectOutput === undefined) { this.debugOption(debugOptions, DebugOptions.RedirectOutput); } diff --git a/src/test/debugger/configProvider/provider.test.ts b/src/test/debugger/configProvider/provider.test.ts index 0ea18a47ac56..84c0148b9491 100644 --- a/src/test/debugger/configProvider/provider.test.ts +++ b/src/test/debugger/configProvider/provider.test.ts @@ -323,7 +323,7 @@ import { IServiceContainer } from '../../../client/ioc/types'; setupIoc(pythonPath, isWindows, isMac, isLinux); setupActiveEditor(pythonFile, PythonLanguage.language); - const execOutput = pyramidExists ? Promise.resolve({ stdout: pyramidFilePath }) : Promise.reject(new Error('No Module')); + const execOutput = pyramidExists ? Promise.resolve({ stdout: pyramidFilePath }) : Promise.reject('No Module'); pythonExecutionService.setup(e => e.exec(TypeMoq.It.isValue(args), TypeMoq.It.isAny())) .returns(() => execOutput) .verifiable(TypeMoq.Times.exactly(addPyramidDebugOption ? 1 : 0)); @@ -337,13 +337,18 @@ import { IServiceContainer } from '../../../client/ioc/types'; const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, options as any as DebugConfiguration); if (shouldWork) { expect(debugConfig).to.have.property('program', pserveFilePath); + + if (provider.debugType === 'pythonExperimental') { + expect(debugConfig).to.have.property('debugOptions'); + expect((debugConfig as any).debugOptions).contains(DebugOptions.Jinja); + } } else { expect(debugConfig!.program).to.be.not.equal(pserveFilePath); } pythonExecutionService.verifyAll(); fileSystem.verifyAll(); appShell.verifyAll(); - } + } test('Program is set for Pyramid (windows)', async () => { await testPyramidConfiguration(true, false, false); });