mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
[python] Make PyOverrideTest work with the latest Python 3 by default
GitOrigin-RevId: fd44fa8ca8a0f3eed2b710a65225979569023d3f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
250ee7e314
commit
fbfaf24bc3
@@ -4,7 +4,7 @@ class Spam(Eggs):
|
||||
|
||||
class Eggs(Spam):
|
||||
def spam_methods(self):
|
||||
super(Eggs, self).spam_methods()
|
||||
super().spam_methods()
|
||||
|
||||
def my_methods(self):
|
||||
pass
|
||||
|
||||
@@ -6,5 +6,5 @@ class A(object):
|
||||
class B(A):
|
||||
@classmethod
|
||||
def m(cls):
|
||||
<selection>super(B, cls).m()</selection>
|
||||
<selection>super().m()</selection>
|
||||
|
||||
|
||||
@@ -6,4 +6,4 @@ class A:
|
||||
class B(A):
|
||||
@classmethod
|
||||
def foo(cls):
|
||||
<selection>A.foo(cls)</selection>
|
||||
<selection>super().foo()</selection>
|
||||
|
||||
@@ -5,5 +5,5 @@ class BaseMeta(type):
|
||||
|
||||
class MyMeta(BaseMeta):
|
||||
def __new__(cls, name, bases, namespace):
|
||||
return super(MyMeta, cls).__new__(cls, name, bases, namespace)
|
||||
return super().__new__(cls, name, bases, namespace)
|
||||
|
||||
|
||||
@@ -4,4 +4,4 @@ class Dialog:
|
||||
class B(Dialog):
|
||||
|
||||
def validate(self):
|
||||
<selection>Dialog.validate(self)</selection>
|
||||
<selection>super().validate()</selection>
|
||||
@@ -9,4 +9,4 @@ class A:
|
||||
|
||||
class B(A):
|
||||
def otherMethod(self, foo, bar):
|
||||
print foo, bar
|
||||
print(foo, bar)
|
||||
|
||||
@@ -5,10 +5,10 @@ class X(object):
|
||||
class A:
|
||||
class Inner(X):
|
||||
def foo(self):
|
||||
<selection>super(A.Inner, self).foo()</selection>
|
||||
<selection>super().foo()</selection>
|
||||
|
||||
def doStuff(self, foo=True): pass
|
||||
|
||||
class B(A):
|
||||
def otherMethod(self, foo, bar):
|
||||
print foo, bar
|
||||
print(foo, bar)
|
||||
|
||||
@@ -6,5 +6,5 @@ class A():
|
||||
def service(self):
|
||||
class B(X):
|
||||
def foo(self):
|
||||
super(B, self).foo()
|
||||
super().foo()
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
|
||||
class MyType(type):
|
||||
def __instancecheck__(self, instance):
|
||||
<selection>return super(MyType, self).__instancecheck__(instance)</selection>
|
||||
def __instancecheck__(self, __instance: Any) -> bool:
|
||||
<selection>return super().__instancecheck__(__instance)</selection>
|
||||
|
||||
@@ -7,5 +7,5 @@ class C(object):
|
||||
class D(C):
|
||||
@property
|
||||
def foo(self):
|
||||
return super(D, self).foo
|
||||
return super().foo
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import turtle
|
||||
from tkinter import Canvas
|
||||
|
||||
|
||||
class C(turtle.TurtleScreenBase):
|
||||
def __init__(self, cv):
|
||||
<selection>super(C, self).__init__(cv)</selection>
|
||||
def __init__(self, cv: Canvas) -> None:
|
||||
<selection>super().__init__(cv)</selection>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ class A:
|
||||
|
||||
class B(A):
|
||||
def doStuff(self, foo=True):
|
||||
<selection>return A.doStuff(self, foo)</selection>
|
||||
<selection>return super().doStuff(foo)</selection>
|
||||
|
||||
def otherMethod(self, foo, bar):
|
||||
print foo, bar
|
||||
|
||||
@@ -6,4 +6,4 @@ class A:
|
||||
class B(A):
|
||||
@staticmethod
|
||||
def foo(cls):
|
||||
<selection>A.foo(cls)</selection>
|
||||
<selection>super().foo(cls)</selection>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.codeInsight.override.PyMethodMember;
|
||||
@@ -23,11 +22,6 @@ import java.util.List;
|
||||
|
||||
public class PyOverrideTest extends PyTestCase {
|
||||
|
||||
@Override
|
||||
protected @Nullable LightProjectDescriptor getProjectDescriptor() {
|
||||
return ourPy2Descriptor;
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(null);
|
||||
}
|
||||
@@ -64,10 +58,6 @@ public class PyOverrideTest extends PyTestCase {
|
||||
PyOverrideImplementUtil.overrideMethods(myFixture.getEditor(), subClass, ContainerUtil.map(implToOverride, PyMethodMember::new), false);
|
||||
}
|
||||
|
||||
private void doTest3k() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON34, this::doTest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures loops in class hierarchy does not lead to SO
|
||||
*/
|
||||
@@ -75,8 +65,8 @@ public class PyOverrideTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
public void testOldStyleClassInPython2() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON27, this::doTest);
|
||||
}
|
||||
|
||||
public void testClassmethod() {
|
||||
@@ -87,8 +77,8 @@ public class PyOverrideTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNewStyle() {
|
||||
doTest();
|
||||
public void testNewStyleClassInPython2() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON27, this::doTest);
|
||||
}
|
||||
|
||||
public void testReturnValue() { // PY-1537
|
||||
@@ -140,17 +130,17 @@ public class PyOverrideTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testPy3k() {
|
||||
doTest3k();
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-15629
|
||||
public void testStaticMethodPy3k() {
|
||||
doTest3k();
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-15629
|
||||
public void testDunderNewPy3k() {
|
||||
doTest3k();
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-15629
|
||||
@@ -159,11 +149,11 @@ public class PyOverrideTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testTypeAnnotations() { // PY-2547
|
||||
doTest3k();
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReturnAnnotation() { // PY-2690
|
||||
doTest3k();
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-18553
|
||||
@@ -180,23 +170,21 @@ public class PyOverrideTest extends PyTestCase {
|
||||
}
|
||||
|
||||
private void doTestImportsForTypeAnnotations() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON35, () -> {
|
||||
myFixture.configureByFiles(getTestName(true) + ".py", getTestName(true) + "_import.py");
|
||||
doOverride(null);
|
||||
myFixture.checkResultByFile(getTestName(true) + "_after.py", true);
|
||||
});
|
||||
myFixture.configureByFiles(getTestName(true) + ".py", getTestName(true) + "_import.py");
|
||||
doOverride(null);
|
||||
myFixture.checkResultByFile(getTestName(true) + "_after.py", true);
|
||||
}
|
||||
|
||||
public void testSingleStar() { // PY-6455
|
||||
doTest3k();
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStarArgs() { // PY-6455
|
||||
doTest3k();
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testKwargs() { // PY-7401
|
||||
doTest3k();
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDocstring() {
|
||||
@@ -210,26 +198,24 @@ public class PyOverrideTest extends PyTestCase {
|
||||
|
||||
// PY-19312
|
||||
public void testAsyncMethod() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON36, this::doTest);
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-30287
|
||||
public void testMethodWithOverloadsInTheSameFile() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest);
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-30287
|
||||
public void testMethodWithOverloadsInAnotherFile() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON35, () -> {
|
||||
myFixture.configureByFiles(getTestName(true) + ".py", getTestName(true) + "_parent.py");
|
||||
doOverride(null);
|
||||
myFixture.checkResultByFile(getTestName(true) + "_after.py", true);
|
||||
});
|
||||
myFixture.configureByFiles(getTestName(true) + ".py", getTestName(true) + "_parent.py");
|
||||
doOverride("B");
|
||||
myFixture.checkResultByFile(getTestName(true) + "_after.py", true);
|
||||
}
|
||||
|
||||
// PY-35512
|
||||
public void testPositionalOnlyParameters() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON38, () -> doTest("B"));
|
||||
doTest("B");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user