From a4805d44860e1f3365566cb7ced3a50c9af16f80 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 17 Apr 2019 17:09:36 -0700 Subject: [PATCH 1/2] Corrected bug and added tests --- src/client/linters/linterInfo.ts | 2 +- src/test/linters/linterinfo.unit.test.ts | 45 ++++++++++++++++-------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/client/linters/linterInfo.ts b/src/client/linters/linterInfo.ts index 1028f0c4ec42..566db9ab59da 100644 --- a/src/client/linters/linterInfo.ts +++ b/src/client/linters/linterInfo.ts @@ -82,7 +82,7 @@ export class PylintLinterInfo extends LinterInfo { } // If we're using new LS, then by default Pylint is disabled (unless the user provides a value). const inspection = this.workspaceService.getConfiguration('python', resource).inspect('linting.pylintEnabled'); - if (!inspection || (inspection.globalValue === undefined && (inspection.workspaceFolderValue === undefined || inspection.workspaceValue === undefined))) { + if (!inspection || (inspection.globalValue === undefined && (inspection.workspaceFolderValue === undefined && inspection.workspaceValue === undefined))) { return false; } return enabled; diff --git a/src/test/linters/linterinfo.unit.test.ts b/src/test/linters/linterinfo.unit.test.ts index 1784a7b61842..ed3522ce004f 100644 --- a/src/test/linters/linterinfo.unit.test.ts +++ b/src/test/linters/linterinfo.unit.test.ts @@ -53,22 +53,37 @@ suite('Linter Info - Pylint', () => { expect(linterInfo.isEnabled()).to.be.false; }); - test('Test enabled when using Language Server and Pylint is configured', async () => { - const config = mock(ConfigurationService); - const workspaceService = mock(WorkspaceService); - const linterInfo = new PylintLinterInfo(instance(config), instance(workspaceService), []); + const testsForisEnabled = + [ + { + testName: 'When workspaceFolder setting is provided', + inspection: { workspaceFolderValue: true } + }, + { + testName: 'When workspace setting is provided', + inspection: { workspaceValue: true } + }, + { + testName: 'When global setting is provided', + inspection: { globalValue: true } + } + ]; - const inspection = { - globalValue: 'something', - workspaceFolderValue: 'something', - workspaceValue: 'something' - }; - const pythonConfig = { - inspect: () => inspection - }; - when(config.getSettings(anything())).thenReturn({ linting: { pylintEnabled: true }, jediEnabled: false } as any); - when(workspaceService.getConfiguration('python', anything())).thenReturn(pythonConfig as any); + suite('Test is enabled when using Language Server and Pylint is configured', () => { + testsForisEnabled.forEach(testParams => { + test(testParams.testName, async () => { + const config = mock(ConfigurationService); + const workspaceService = mock(WorkspaceService); + const linterInfo = new PylintLinterInfo(instance(config), instance(workspaceService), []); - expect(linterInfo.isEnabled()).to.be.true; + const pythonConfig = { + inspect: () => testParams.inspection + }; + when(config.getSettings(anything())).thenReturn({ linting: { pylintEnabled: true }, jediEnabled: false } as any); + when(workspaceService.getConfiguration('python', anything())).thenReturn(pythonConfig as any); + + expect(linterInfo.isEnabled()).to.be.true; + }); + }); }); }); From e3b7b05e0413a0c5780378a2e97144dff3187731 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 17 Apr 2019 17:13:48 -0700 Subject: [PATCH 2/2] News entry --- news/2 Fixes/5087.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/2 Fixes/5087.md diff --git a/news/2 Fixes/5087.md b/news/2 Fixes/5087.md new file mode 100644 index 000000000000..1d7f1f9dd4fb --- /dev/null +++ b/news/2 Fixes/5087.md @@ -0,0 +1 @@ +No prompt displayed to install pylint