@@ -9,20 +9,20 @@ import { expect, use } from 'chai';
9
9
import * as chaiAsPromised from 'chai-as-promised' ;
10
10
import * as path from 'path' ;
11
11
import * as sinon from 'sinon' ;
12
- import rewiremock from 'rewiremock' ;
13
12
import { SemVer } from 'semver' ;
14
13
import { instance , mock , when } from 'ts-mockito' ;
15
14
import { DebugAdapterExecutable , DebugAdapterServer , DebugConfiguration , DebugSession , WorkspaceFolder } from 'vscode' ;
16
15
import { IPersistentStateFactory } from '../../../extension/common/types' ;
17
16
import { DebugAdapterDescriptorFactory , debugStateKeys } from '../../../extension/debugger/adapter/factory' ;
18
17
import { IDebugAdapterDescriptorFactory } from '../../../extension/debugger/types' ;
19
- import { clearTelemetryReporter } from '../../../extension/telemetry' ;
20
18
import { EventName } from '../../../extension/telemetry/constants' ;
21
19
import { PersistentState , PersistentStateFactory } from '../../../extension/common/persistentState' ;
22
- import * as vscodeApi from '../../../extension/common/vscodeapi' ;
23
20
import { EXTENSION_ROOT_DIR } from '../../../extension/common/constants' ;
24
21
import { Architecture } from '../../../extension/common/platform' ;
25
22
import * 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' ;
26
26
import { DebugConfigStrings } from '../../../extension/common/utils/localize' ;
27
27
28
28
use ( chaiAsPromised ) ;
@@ -36,6 +36,8 @@ suite('Debugging - Adapter Factory', () => {
36
36
let getInterpretersStub : sinon . SinonStub ;
37
37
let getInterpreterDetailsStub : sinon . SinonStub ;
38
38
let hasInterpretersStub : sinon . SinonStub ;
39
+ let getTelemetryReporterStub : sinon . SinonStub ;
40
+ let reporter : any ;
39
41
40
42
const nodeExecutable = undefined ;
41
43
const debugAdapterPath = path . join ( EXTENSION_ROOT_DIR , 'bundled' , 'libs' , 'debugpy' , 'adapter' ) ;
@@ -65,22 +67,23 @@ suite('Debugging - Adapter Factory', () => {
65
67
setup ( ( ) => {
66
68
process . env . VSC_PYTHON_UNIT_TEST = undefined ;
67
69
process . env . VSC_PYTHON_CI_TEST = undefined ;
68
- rewiremock . enable ( ) ;
69
- rewiremock ( '@vscode/extension-telemetry' ) . with ( { default : Reporter } ) ;
70
+ reporter = new Reporter ( ) ;
71
+
70
72
stateFactory = mock ( PersistentStateFactory ) ;
71
73
state = mock ( PersistentState ) as PersistentState < boolean | undefined > ;
72
74
showErrorMessageStub = sinon . stub ( vscodeApi , 'showErrorMessage' ) ;
73
75
resolveEnvironmentStub = sinon . stub ( pythonApi , 'resolveEnvironment' ) ;
74
76
getInterpretersStub = sinon . stub ( pythonApi , 'getInterpreters' ) ;
75
77
getInterpreterDetailsStub = sinon . stub ( pythonApi , 'getInterpreterDetails' ) ;
76
78
hasInterpretersStub = sinon . stub ( pythonApi , 'hasInterpreters' ) ;
79
+ getTelemetryReporterStub = sinon . stub ( telemetryReporter , 'getTelemetryReporter' ) ;
77
80
78
81
when (
79
82
stateFactory . createGlobalPersistentState < boolean | undefined > ( debugStateKeys . doNotShowAgain , false ) ,
80
83
) . thenReturn ( instance ( state ) ) ;
81
-
82
84
getInterpretersStub . returns ( [ interpreter ] ) ;
83
85
hasInterpretersStub . returns ( true ) ;
86
+ getTelemetryReporterStub . returns ( reporter ) ;
84
87
factory = new DebugAdapterDescriptorFactory ( instance ( stateFactory ) ) ;
85
88
} ) ;
86
89
@@ -90,8 +93,7 @@ suite('Debugging - Adapter Factory', () => {
90
93
Reporter . properties = [ ] ;
91
94
Reporter . eventNames = [ ] ;
92
95
Reporter . measures = [ ] ;
93
- rewiremock . disable ( ) ;
94
- clearTelemetryReporter ( ) ;
96
+ telemetry . clearTelemetryReporter ( ) ;
95
97
sinon . restore ( ) ;
96
98
} ) ;
97
99
0 commit comments