1+
2+ // // Note: This example test is leveraging the Mocha test framework.
3+ // // Please refer to their documentation on https://mochajs.org/ for help.
4+
5+
6+ // // The module 'assert' provides assertion methods from node
7+ // import * as assert from 'assert';
8+
9+ // // You can import and use all API from the 'vscode' module
10+ // // as well as import your extension to test it
11+ // import * as vscode from 'vscode';
12+ // import * as path from 'path';
13+ // import * as settings from '../client/common/configSettings';
14+ // import * as fs from 'fs-extra';
15+ // import { initialize } from './initialize';
16+ // import { execPythonFile } from '../client/common/utils';
17+
18+ // import { iPythonAdapter } from '../client/jupyter/comms/ipythonAdapter';
19+ // import { SocketServer } from '../client/common/comms/socketServer';
20+ // import * as child_process from 'child_process';
21+ // import { createDeferred } from '../client/common/helpers';
22+
23+ // let pythonSettings = settings.PythonSettings.getInstance();
24+ // let ch = vscode.window.createOutputChannel('Tests');
25+ // let outputChannel = ch;
26+ // let pythoFilesPath = path.join(__dirname, '..', '..', 'src', 'test', 'pythonFiles', 'formatting');
27+
28+ // let childProc: child_process.ChildProcess;
29+ // let socketServer: SocketServer;
30+ // let ipythonAdapter: iPythonAdapter;
31+
32+ // suiteSetup(done => {
33+ // initialize().then(() => {
34+ // const pyFile = path.join(__dirname, '..', '..', '..', '..', 'pythonFiles', 'PythonTools', 'ipythonServer.py');
35+ // socketServer = new SocketServer();
36+ // ipythonAdapter = new iPythonAdapter(this.socketServer);
37+ // socketServer.Start().then(port => {
38+ // const def = createDeferred<any>();
39+ // // We want to test this
40+ // const newEnv = { "TEST_DJAYAMANNE_IPYTHON": "1" };
41+ // Object.assign(newEnv, process.env);
42+
43+ // // Any version of python will do, even without jupyter or ipython
44+ // childProc = child_process.spawn('python', [pyFile, port.toString()], { env: newEnv });
45+ // childProc.stdout.setEncoding('utf8');
46+ // childProc.stderr.setEncoding('utf8');
47+
48+ // childProc.stdout.on('data', (data: string) => {
49+ // outputChannel.append(data);
50+ // });
51+ // childProc.stderr.on('data', (data: string) => {
52+ // outputChannel.append(data);
53+ // });
54+ // done();
55+
56+ // // setTimeout(() => {
57+ // // //this.socketServer.
58+ // // this.ipythonAdapter.ping();
59+ // // this.ipythonAdapter.listKernels().then(x => {
60+ // // const y = x;
61+ // // }, reason => {
62+ // // const y = reason;
63+ // // })
64+ // // }, 1000);
65+ // });
66+ // }, done);
67+ // });
68+
69+ // suiteTeardown(() => {
70+ // });
71+
72+ // suite('Formatting', () => {
73+ // teardown(() => {
74+ // if (vscode.window.activeTextEditor) {
75+ // return vscode.commands.executeCommand('workbench.action.closeActiveEditor');
76+ // }
77+ // });
78+ // function testFormatting(formatter: AutoPep8Formatter | YapfFormatter, formattedContents: string, fileToFormat: string): PromiseLike<void> {
79+ // let textEditor: vscode.TextEditor;
80+ // let textDocument: vscode.TextDocument;
81+ // return vscode.workspace.openTextDocument(fileToFormat).then(document => {
82+ // textDocument = document;
83+ // return vscode.window.showTextDocument(textDocument);
84+ // }).then(editor => {
85+ // textEditor = editor;
86+ // return formatter.formatDocument(textDocument, null, null);
87+ // }).then(edits => {
88+ // return textEditor.edit(editBuilder => {
89+ // edits.forEach(edit => editBuilder.replace(edit.range, edit.newText));
90+ // });
91+ // }).then(edited => {
92+ // assert.equal(textEditor.document.getText(), formattedContents, 'Formatted text is not the same');
93+ // });
94+ // }
95+ // test('AutoPep8', done => {
96+ // testFormatting(new AutoPep8Formatter(ch, pythonSettings, pythoFilesPath), formattedAutoPep8, autoPep8FileToFormat).then(done, done);
97+ // });
98+
99+ // test('Yapf', done => {
100+ // testFormatting(new YapfFormatter(ch, pythonSettings, pythoFilesPath), formattedYapf, yapfFileToFormat).then(done, done);
101+ // });
102+ // });
0 commit comments