TddCodeGenerationQuickFixParticipant quickFix;
PySelection ps;
List<ICompletionProposal> props;
IFile mod2 = initFile.getParent().getFile(new Path("other_module.py"));
mod2.create(new ByteArrayInputStream("".getBytes()), true, null);
PyEdit editor2 = (PyEdit) PyOpenEditor.doOpenEditor(mod2);
try {
goToManual(AnalysisRequestsTestWorkbench.TIME_FOR_ANALYSIS); //give it a bit more time...
mod1Contents = "" +
"import other_module\n" +
"other_module.Foo";
setContentsAndWaitReparseAndError(mod1Contents);
quickFix = new TddCodeGenerationQuickFixParticipant();
int offset = mod1Contents.length() - 1;
ps = new PySelection(editor.getDocument(), offset);
assertTrue(quickFix.isValid(ps, "", editor, offset));
props = waitForQuickFixProps(quickFix, ps, offset);
findCompletion(props, "Create Foo class at other_module.py").apply(editor.getISourceViewer(), '\n', 0,
offset);
assertContentsEqual("" +
"class Foo(object):\n" +
" pass\n" +
"\n" +
"\n" +
"", editor2.getDocument()
.get());
} finally {
editor2.close(false);
mod2.delete(true, null);
}
}