Skip to content

Commit b972ba7

Browse files
committed
fix method extraction
1 parent ca48439 commit b972ba7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/test/extension.refactor.extract.method.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ class MockTextDocument implements vscode.TextDocument {
9393
suite('Method Extraction', () => {
9494
// Hack hac hack
9595
const oldExecuteCommand = vscode.commands.executeCommand;
96+
const options: vscode.TextEditorOptions = { cursorStyle: vscode.TextEditorCursorStyle.Line, insertSpaces: true, lineNumbers: vscode.TextEditorLineNumbersStyle.Off, tabSize: 4 };
97+
9698
suiteSetup(done => {
9799
fs.copySync(refactorSourceFile, refactorTargetFile, { clobber: true });
98100
pythonSettings.pythonPath = PYTHON_PATH;
@@ -125,8 +127,7 @@ suite('Method Extraction', () => {
125127

126128
const DIFF = `--- a/refactor.py\n+++ b/refactor.py\n@@ -237,9 +237,12 @@\n try:\n self._process_request(self._input.readline())\n except Exception as ex:\n- message = ex.message + ' \\n' + traceback.format_exc()\n- sys.stderr.write(str(len(message)) + ':' + message)\n- sys.stderr.flush()\n+ self.myNewMethod(ex)\n+\n+ def myNewMethod(self, ex):\n+ message = ex.message + ' \\n' + traceback.format_exc()\n+ sys.stderr.write(str(len(message)) + ':' + message)\n+ sys.stderr.flush()\n \n if __name__ == '__main__':\n RopeRefactoring().watch()\n`;
127129
let expectedTextEdits = getTextEditsFromPatch(mockTextDoc.getText(), DIFF);
128-
129-
return proxy.extractMethod<RenameResponse>(mockTextDoc, 'myNewMethod', refactorTargetFile, rangeOfTextToExtract)
130+
return proxy.extractMethod<RenameResponse>(mockTextDoc, 'myNewMethod', refactorTargetFile, rangeOfTextToExtract, options)
130131
.then(response => {
131132
if (shouldError) {
132133
ignoreErrorHandling = true;
@@ -188,7 +189,7 @@ suite('Method Extraction', () => {
188189
assert.fail('No error', 'Error', 'Extraction should fail with an error', '');
189190
}
190191
return textEditor.document.save();
191-
}).then(()=>{
192+
}).then(() => {
192193
assert.equal(ch.output.length, 0, 'Output channel is not empty');
193194
assert.equal(textDocument.lineAt(241).text.trim().indexOf('def newmethod'), 0, 'New Method not created');
194195
assert.equal(textDocument.lineAt(239).text.trim().startsWith('self.newmethod'), true, 'New Method not being used');

0 commit comments

Comments
 (0)