Skip to content

Commit 1943c5c

Browse files
committed
add test for native repl instance disposal
1 parent 265a273 commit 1943c5c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/test/repl/nativeRepl.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,26 @@ suite('REPL - Native REPL', () => {
9595
setReplDirectoryStub.restore();
9696
setReplControllerSpy.restore();
9797
});
98+
99+
test('Closing REPL should dispose of the previous instance and create a new one on reopening', async () => {
100+
const disposeSpy = sinon.spy(NativeRepl.prototype, 'dispose');
101+
const createStub = sinon.stub(NativeRepl, 'create').callThrough();
102+
interpreterService
103+
.setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny()))
104+
.returns(() => Promise.resolve(({ path: 'ps' } as unknown) as PythonEnvironment));
105+
const interpreter = await interpreterService.object.getActiveInterpreter();
106+
107+
const firstRepl = await getNativeRepl(interpreter as PythonEnvironment, disposableArray);
108+
109+
firstRepl.dispose();
110+
111+
const secondRepl = await getNativeRepl(interpreter as PythonEnvironment, disposableArray);
112+
113+
expect(disposeSpy.calledOnce).to.be.true;
114+
expect(createStub.calledTwice).to.be.true;
115+
expect(firstRepl).to.not.equal(secondRepl);
116+
117+
disposeSpy.restore();
118+
createStub.restore();
119+
});
98120
});

0 commit comments

Comments
 (0)