@@ -9,20 +9,20 @@ import { expect, use } from 'chai';
99import * as chaiAsPromised from 'chai-as-promised' ;
1010import * as path from 'path' ;
1111import * as sinon from 'sinon' ;
12- import rewiremock from 'rewiremock' ;
1312import { SemVer } from 'semver' ;
1413import { instance , mock , when } from 'ts-mockito' ;
1514import { DebugAdapterExecutable , DebugAdapterServer , DebugConfiguration , DebugSession , WorkspaceFolder } from 'vscode' ;
1615import { IPersistentStateFactory } from '../../../extension/common/types' ;
1716import { DebugAdapterDescriptorFactory , debugStateKeys } from '../../../extension/debugger/adapter/factory' ;
1817import { IDebugAdapterDescriptorFactory } from '../../../extension/debugger/types' ;
19- import { clearTelemetryReporter } from '../../../extension/telemetry' ;
2018import { EventName } from '../../../extension/telemetry/constants' ;
2119import { PersistentState , PersistentStateFactory } from '../../../extension/common/persistentState' ;
22- import * as vscodeApi from '../../../extension/common/vscodeapi' ;
2320import { EXTENSION_ROOT_DIR } from '../../../extension/common/constants' ;
2421import { Architecture } from '../../../extension/common/platform' ;
2522import * as pythonApi from '../../../extension/common/python' ;
23+ import * as telemetry from '../../../extension/telemetry' ;
24+ import * as telemetryReporter from '../../../extension/telemetry/reporter' ;
25+ import * as vscodeApi from '../../../extension/common/vscodeapi' ;
2626import { DebugConfigStrings } from '../../../extension/common/utils/localize' ;
2727
2828use ( chaiAsPromised ) ;
@@ -36,6 +36,8 @@ suite('Debugging - Adapter Factory', () => {
3636 let getInterpretersStub : sinon . SinonStub ;
3737 let getInterpreterDetailsStub : sinon . SinonStub ;
3838 let hasInterpretersStub : sinon . SinonStub ;
39+ let getTelemetryReporterStub : sinon . SinonStub ;
40+ let reporter : any ;
3941
4042 const nodeExecutable = undefined ;
4143 const debugAdapterPath = path . join ( EXTENSION_ROOT_DIR , 'bundled' , 'libs' , 'debugpy' , 'adapter' ) ;
@@ -65,22 +67,23 @@ suite('Debugging - Adapter Factory', () => {
6567 setup ( ( ) => {
6668 process . env . VSC_PYTHON_UNIT_TEST = undefined ;
6769 process . env . VSC_PYTHON_CI_TEST = undefined ;
68- rewiremock . enable ( ) ;
69- rewiremock ( '@vscode/extension-telemetry' ) . with ( { default : Reporter } ) ;
70+ reporter = new Reporter ( ) ;
71+
7072 stateFactory = mock ( PersistentStateFactory ) ;
7173 state = mock ( PersistentState ) as PersistentState < boolean | undefined > ;
7274 showErrorMessageStub = sinon . stub ( vscodeApi , 'showErrorMessage' ) ;
7375 resolveEnvironmentStub = sinon . stub ( pythonApi , 'resolveEnvironment' ) ;
7476 getInterpretersStub = sinon . stub ( pythonApi , 'getInterpreters' ) ;
7577 getInterpreterDetailsStub = sinon . stub ( pythonApi , 'getInterpreterDetails' ) ;
7678 hasInterpretersStub = sinon . stub ( pythonApi , 'hasInterpreters' ) ;
79+ getTelemetryReporterStub = sinon . stub ( telemetryReporter , 'getTelemetryReporter' ) ;
7780
7881 when (
7982 stateFactory . createGlobalPersistentState < boolean | undefined > ( debugStateKeys . doNotShowAgain , false ) ,
8083 ) . thenReturn ( instance ( state ) ) ;
81-
8284 getInterpretersStub . returns ( [ interpreter ] ) ;
8385 hasInterpretersStub . returns ( true ) ;
86+ getTelemetryReporterStub . returns ( reporter ) ;
8487 factory = new DebugAdapterDescriptorFactory ( instance ( stateFactory ) ) ;
8588 } ) ;
8689
@@ -90,8 +93,7 @@ suite('Debugging - Adapter Factory', () => {
9093 Reporter . properties = [ ] ;
9194 Reporter . eventNames = [ ] ;
9295 Reporter . measures = [ ] ;
93- rewiremock . disable ( ) ;
94- clearTelemetryReporter ( ) ;
96+ telemetry . clearTelemetryReporter ( ) ;
9597 sinon . restore ( ) ;
9698 } ) ;
9799
0 commit comments