mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
merge in-place and regular tests for introduce field
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
class SomeClass():
|
||||
def a(self):
|
||||
self.a = 1
|
||||
@@ -0,0 +1,3 @@
|
||||
class SomeClass():
|
||||
def a(self):
|
||||
<selection>1</selection>
|
||||
@@ -0,0 +1,12 @@
|
||||
import math
|
||||
|
||||
__author__ = 'wombat'
|
||||
class SolverEquation:
|
||||
def demo(self):
|
||||
a = 3
|
||||
b = 25
|
||||
c = 46
|
||||
self.a = math.sqrt(b ** 2 - 4 * a * c)
|
||||
root1 = (-b + self.a) / (2*a)
|
||||
root2 = (-b - self.a) / (2*a)
|
||||
print(root1,root2)
|
||||
@@ -0,0 +1,11 @@
|
||||
import math
|
||||
|
||||
__author__ = 'wombat'
|
||||
class SolverEquation:
|
||||
def demo(self):
|
||||
a = 3
|
||||
b = 25
|
||||
c = 46
|
||||
root1 = (-b + <selection>math.sqrt(b ** 2 - 4 * a * c)</selection>) / (2*a)
|
||||
root2 = (-b - math.sqrt(b ** 2 - 4 * a * c)) / (2*a)
|
||||
print(root1,root2)
|
||||
@@ -62,7 +62,6 @@ public class PythonAllTestsSuite {
|
||||
PyStatementMoverTest.class,
|
||||
PyIntroduceVariableTest.class,
|
||||
PyIntroduceFieldTest.class,
|
||||
PyInplaceIntroduceFieldTest.class,
|
||||
PyIntroduceConstantTest.class,
|
||||
PyClassNameCompletionTest.class,
|
||||
PySuppressInspectionsTest.class,
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.jetbrains.python.refactoring;
|
||||
|
||||
import com.intellij.codeInsight.template.TemplateManager;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.jetbrains.python.fixtures.PyLightFixtureTestCase;
|
||||
import com.jetbrains.python.refactoring.introduce.IntroduceOperation;
|
||||
import com.jetbrains.python.refactoring.introduce.field.PyIntroduceFieldHandler;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PyInplaceIntroduceFieldTest extends PyLightFixtureTestCase {
|
||||
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
|
||||
public PyInplaceIntroduceFieldTest() {
|
||||
PyLightFixtureTestCase.initPlatformPrefix();
|
||||
}
|
||||
|
||||
public void testPy4453() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPy4414() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
String name = getTestName(true);
|
||||
myFixture.configureByFile("refactoring/inplaceIntroduceField/" + name + ".py");
|
||||
final boolean enabled = myFixture.getEditor().getSettings().isVariableInplaceRenameEnabled();
|
||||
TemplateManagerImpl templateManager = (TemplateManagerImpl)TemplateManager.getInstance(LightPlatformTestCase.getProject());
|
||||
try {
|
||||
templateManager.setTemplateTesting(true);
|
||||
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(true);
|
||||
|
||||
PyIntroduceFieldHandler handler = new PyIntroduceFieldHandler();
|
||||
final IntroduceOperation introduceOperation = new IntroduceOperation(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), "a",
|
||||
false, false);
|
||||
introduceOperation.setReplaceAll(true);
|
||||
handler.performAction(introduceOperation);
|
||||
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(myFixture.getEditor());
|
||||
assert state != null;
|
||||
state.gotoEnd(false);
|
||||
myFixture.checkResultByFile("refactoring/inplaceIntroduceField/" + name + ".after.py", true);
|
||||
}
|
||||
finally {
|
||||
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
|
||||
templateManager.setTemplateTesting(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,14 @@ public class PyIntroduceFieldTest extends PyIntroduceTestCase {
|
||||
doTestSuggestions(PyExpression.class, "s1");
|
||||
}
|
||||
|
||||
public void testPy4453() {
|
||||
doTestInplace();
|
||||
}
|
||||
|
||||
public void testPy4414() {
|
||||
doTestInplace();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IntroduceHandler createHandler() {
|
||||
return new PyIntroduceFieldHandler();
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.jetbrains.python.refactoring;
|
||||
|
||||
import com.intellij.codeInsight.template.TemplateManager;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.jetbrains.python.fixtures.PyLightFixtureTestCase;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
@@ -51,4 +55,30 @@ public abstract class PyIntroduceTestCase extends PyLightFixtureTestCase {
|
||||
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(inplaceEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doTestInplace() {
|
||||
String name = getTestName(true);
|
||||
myFixture.configureByFile(name + ".py");
|
||||
final boolean enabled = myFixture.getEditor().getSettings().isVariableInplaceRenameEnabled();
|
||||
TemplateManagerImpl templateManager = (TemplateManagerImpl)TemplateManager.getInstance(LightPlatformTestCase.getProject());
|
||||
try {
|
||||
templateManager.setTemplateTesting(true);
|
||||
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(true);
|
||||
|
||||
IntroduceHandler handler = createHandler();
|
||||
final IntroduceOperation introduceOperation = new IntroduceOperation(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), "a",
|
||||
false, false);
|
||||
introduceOperation.setReplaceAll(true);
|
||||
handler.performAction(introduceOperation);
|
||||
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(myFixture.getEditor());
|
||||
assert state != null;
|
||||
state.gotoEnd(false);
|
||||
myFixture.checkResultByFile(name + ".after.py", true);
|
||||
}
|
||||
finally {
|
||||
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
|
||||
templateManager.setTemplateTesting(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user