mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-18839: Provide not only function, but also class name
If method is declared in parent, abstract class, you can't run method only. You also need to know class.
This commit is contained in:
@@ -46,6 +46,7 @@ import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import com.jetbrains.python.sdk.PythonEnvUtil;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import com.jetbrains.python.testing.PyPsiLocationWithFixedClass;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -431,6 +432,9 @@ public abstract class AbstractPythonRunConfiguration<T extends AbstractPythonRun
|
||||
public String getTestSpec(@NotNull final Location<?> location, @NotNull final AbstractTestProxy failedTest) {
|
||||
PsiElement element = location.getPsiElement();
|
||||
PyClass pyClass = PsiTreeUtil.getParentOfType(element, PyClass.class, false);
|
||||
if (location instanceof PyPsiLocationWithFixedClass) {
|
||||
pyClass = ((PyPsiLocationWithFixedClass)location).getFixedClass();
|
||||
}
|
||||
PyFunction pyFunction = PsiTreeUtil.getParentOfType(element, PyFunction.class, false);
|
||||
final VirtualFile virtualFile = location.getVirtualFile();
|
||||
if (virtualFile != null) {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.python.testing;
|
||||
|
||||
import com.intellij.execution.PsiLocation;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* PSI-based location may point to function, but function may be situated in abstract class.
|
||||
* So, we need point to real class as well.
|
||||
*
|
||||
* @author Ilya.Kazakevich
|
||||
*/
|
||||
public final class PyPsiLocationWithFixedClass extends PsiLocation<PyFunction> {
|
||||
@NotNull
|
||||
private final PyClass myFixedClass;
|
||||
|
||||
PyPsiLocationWithFixedClass(@NotNull final Project project,
|
||||
@NotNull final PyFunction psiElement,
|
||||
@NotNull final PyClass fixedClass) {
|
||||
super(project, psiElement);
|
||||
myFixedClass = fixedClass;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PyClass getFixedClass() {
|
||||
return myFixedClass;
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ public class PythonUnitTestUtil {
|
||||
continue;
|
||||
}
|
||||
|
||||
locations.add(new PsiLocation<PyFunction>(project, method));
|
||||
locations.add(new PyPsiLocationWithFixedClass(project, method, cls));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user