Skip to content

Commit 2cc7007

Browse files
committed
add more test and clean up
1 parent 73952bb commit 2cc7007

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

src/client/terminals/codeExecution/helper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
120120
}
121121
// For new _pyrepl for Python3.13 and above, we need to send code via bracketed paste mode.
122122
if (object.attach_bracket_paste) {
123-
// return `\u001b[200~${object.normalized.trim()}\u001b[201~`;
124123
let trimmedNormalized = object.normalized.replace(/\n$/, '');
125124
if (trimmedNormalized.endsWith(':\n')) {
126125
// In case where statement is unfinished via :, truncate so auto-indentation lands nicely.

src/test/terminals/codeExecution/helper.test.ts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { ICodeExecutionHelper } from '../../../client/terminals/types';
3636
import { PYTHON_PATH } from '../../common';
3737

3838
const TEST_FILES_PATH = path.join(EXTENSION_ROOT_DIR, 'src', 'test', 'python_files', 'terminalExec');
39-
// TODO: tests for 3.13 relevant sequences
39+
4040
suite('Terminal - Code Execution Helper', () => {
4141
let activeResourceService: TypeMoq.IMock<IActiveResourceService>;
4242
let documentManager: TypeMoq.IMock<IDocumentManager>;
@@ -53,8 +53,8 @@ suite('Terminal - Code Execution Helper', () => {
5353
let jsonParseStub: sinon.SinonStub;
5454
const workingPython: PythonEnvironment = {
5555
path: PYTHON_PATH,
56-
version: new SemVer('3.13.0'),
57-
sysVersion: '3.13.0',
56+
version: new SemVer('3.6.6-final'),
57+
sysVersion: '1.0.0.0',
5858
sysPrefix: 'Python',
5959
displayName: 'Python',
6060
envType: EnvironmentType.Unknown,
@@ -166,6 +166,36 @@ suite('Terminal - Code Execution Helper', () => {
166166
jsonParseStub.restore();
167167
});
168168

169+
test('normalizeLines should not attach bracketed paste for < 3.13', async () => {
170+
jsonParseStub = sinon.stub(JSON, 'parse');
171+
const mockResult = {
172+
normalized: 'print("Looks like you are not on 3.13")',
173+
attach_bracket_paste: false,
174+
};
175+
jsonParseStub.returns(mockResult);
176+
177+
configurationService
178+
.setup((c) => c.getSettings(TypeMoq.It.isAny()))
179+
.returns({
180+
REPL: {
181+
EnableREPLSmartSend: false,
182+
REPLSmartSend: false,
183+
},
184+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
185+
} as any);
186+
const actualProcessService = new ProcessService();
187+
processService
188+
.setup((p) => p.execObservable(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
189+
.returns((file, args, options) =>
190+
actualProcessService.execObservable.apply(actualProcessService, [file, args, options]),
191+
);
192+
193+
const result = await helper.normalizeLines('print("Looks like you are not on 3.13")');
194+
195+
expect(result).to.equal('print("Looks like you are not on 3.13")');
196+
jsonParseStub.restore();
197+
});
198+
169199
test('normalizeLines should call normalizeSelection.py', async () => {
170200
jsonParseStub.restore();
171201
let execArgs = '';
@@ -219,7 +249,6 @@ suite('Terminal - Code Execution Helper', () => {
219249
path.join(TEST_FILES_PATH, `sample${fileNameSuffix}_normalized_selection.py`),
220250
'utf8',
221251
);
222-
// python3 -m pythonFiles.tests
223252
await ensureCodeIsNormalized(code, expectedCode);
224253
});
225254
});

0 commit comments

Comments
 (0)