@@ -23,6 +23,7 @@ const pep8ConfigPath = path.join(pythoFilesPath, 'pep8config');
2323const pydocstyleConfigPath27 = path . join ( pythoFilesPath , 'pydocstyleconfig27' ) ;
2424const pylintConfigPath = path . join ( pythoFilesPath , 'pylintconfig' ) ;
2525const fileToLint = path . join ( pythoFilesPath , 'file.py' ) ;
26+ const threeLineLintsPath = path . join ( pythoFilesPath , 'threeLineLints.py' ) ;
2627
2728const pylintMessagesToBeReturned : ILintMessage [ ] = [
2829 { line : 24 , column : 0 , severity : LintMessageSeverity . Information , code : 'I0011' , message : 'Locally disabling no-member (E1101)' , provider : '' , type : '' } ,
@@ -279,4 +280,22 @@ suite('Linting - General Tests', () => {
279280 assert . notEqual ( messages ! . filter ( x => x . source === 'pylint' ) . length , 0 , 'No pylint messages.' ) ;
280281 assert . notEqual ( messages ! . filter ( x => x . source === 'flake8' ) . length , 0 , 'No flake8 messages.' ) ;
281282 } ) ;
283+ // tslint:disable-next-line:no-any
284+ async function testLinterMessageCount ( product : Product , pythonFile : string , messageCountToBeReceived : number ) : Promise < any > {
285+ const outputChannel = ioc . serviceContainer . get < MockOutputChannel > ( IOutputChannel , STANDARD_OUTPUT_CHANNEL ) ;
286+ const cancelToken = new CancellationTokenSource ( ) ;
287+ const document = await workspace . openTextDocument ( pythonFile ) ;
288+
289+ await linterManager . setActiveLintersAsync ( [ product ] , document . uri ) ;
290+ const linter = linterManager . createLinter ( product , outputChannel , ioc . serviceContainer ) ;
291+
292+ const messages = await linter . lint ( document , cancelToken . token ) ;
293+ assert . equal ( messages . length , messageCountToBeReceived , 'Expected number of lint errors does not match lint error count' ) ;
294+ }
295+ test ( 'Three line output counted as one message' , async ( ) => {
296+ const maxErrors = 5 ;
297+ const target = IS_MULTI_ROOT_TEST ? ConfigurationTarget . WorkspaceFolder : ConfigurationTarget . Workspace ;
298+ await configService . updateSettingAsync ( 'linting.maxNumberOfProblems' , maxErrors , rootWorkspaceUri , target ) ;
299+ await testLinterMessageCount ( Product . pylint , threeLineLintsPath , maxErrors ) ;
300+ } ) ;
282301} ) ;
0 commit comments