@@ -440,6 +440,42 @@ let testCounter = 0;
440440 const pauseLocation = { path: path.join(debugFilesPath, 'sample3WithEx.py'), line: 5 };
441441 await debugClient.assertStoppedLocation('exception', pauseLocation);
442442 });
443+ test('Test pausing on assert failures', async () => {
444+ const pauseLocation = { path: path.join(debugFilesPath, 'sampleWithAssertEx.py'), line: 1 };
445+
446+ function waitToStopDueToException() {
447+ return new Promise((resolve, reject) => {
448+ debugClient.once('stopped', (event: DebugProtocol.StoppedEvent) => {
449+ if (event.body.reason === 'exception' &&
450+ event.body.text && event.body.text!.startsWith('AssertionError')) {
451+ resolve();
452+ } else {
453+ reject(new Error('Stopped for some other reason'));
454+ }
455+ });
456+ setTimeout(() => {
457+ reject(new Error(`waitToStopDueToException not received after ${debugClient.defaultTimeout} ms`));
458+ }, debugClient.defaultTimeout);
459+ });
460+ }
461+
462+ function setBreakpointFilter(): Promise<any> {
463+ if (debuggerType === 'python') {
464+ return Promise.resolve();
465+ } else {
466+ return debugClient.waitForEvent('initialized')
467+ .then(() => debugClient.setExceptionBreakpointsRequest({ filters: ['uncaught'] }))
468+ .then(() => debugClient.configurationDoneRequest());
469+ }
470+ }
471+ await Promise.all([
472+ debugClient.configurationSequence(),
473+ setBreakpointFilter(),
474+ debugClient.launch(buildLauncArgs('sampleWithAssertEx.py', false)),
475+ waitToStopDueToException(),
476+ debugClient.assertStoppedLocation('exception', pauseLocation)
477+ ]);
478+ });
443479 test('Test multi-threaded debugging', async function () {
444480 if (debuggerType !== 'python') {
445481 // See GitHub issue #1250
0 commit comments