mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-28075: twisted trial, as unittest, can't run on plain functions
This commit is contained in:
@@ -55,6 +55,7 @@ import com.jetbrains.extenstions.QNameResolveContext
|
||||
import com.jetbrains.extenstions.getElementAndResolvableName
|
||||
import com.jetbrains.extenstions.resolveToElement
|
||||
import com.jetbrains.python.PyBundle
|
||||
import com.jetbrains.python.PyNames
|
||||
import com.jetbrains.python.psi.PyFile
|
||||
import com.jetbrains.python.psi.PyFunction
|
||||
import com.jetbrains.python.psi.PyQualifiedNameOwner
|
||||
@@ -101,7 +102,8 @@ internal fun getAdditionalArgumentsPropertyName() = com.jetbrains.python.testing
|
||||
/**
|
||||
* If runner name is here that means test runner only can run inheritors for TestCase
|
||||
*/
|
||||
val RunnersThatRequireTestCaseClass = setOf(PythonTestConfigurationsModel.PYTHONS_UNITTEST_NAME)
|
||||
val RunnersThatRequireTestCaseClass = setOf<String>(PythonTestConfigurationsModel.PYTHONS_UNITTEST_NAME,
|
||||
PyTestFrameworkService.getSdkReadableNameByFramework(PyNames.TRIAL_TEST))
|
||||
|
||||
/**
|
||||
* Checks if element could be test target
|
||||
|
||||
+22
@@ -17,12 +17,16 @@ package com.jetbrains.env.python.testing;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.jetbrains.env.EnvTestTagsRequired;
|
||||
import com.jetbrains.env.PyEnvTestCase;
|
||||
import com.jetbrains.env.ut.PyScriptTestProcessRunner;
|
||||
import com.jetbrains.env.ut.PyUnitTestProcessRunner;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.sdk.flavors.IronPythonSdkFlavor;
|
||||
import com.jetbrains.python.testing.PyUnitTestConfiguration;
|
||||
import com.jetbrains.python.testing.PythonTestConfigurationsModel;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Assert;
|
||||
@@ -326,4 +330,22 @@ public abstract class PythonUnitTestingLikeTest<T extends PyScriptTestProcessRun
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleCases() {
|
||||
runPythonTest(
|
||||
new CreateConfigurationMultipleCasesTask<PyUnitTestConfiguration>(PythonTestConfigurationsModel.PYTHONS_UNITTEST_NAME,
|
||||
PyUnitTestConfiguration.class) {
|
||||
@Override
|
||||
protected boolean configurationShouldBeProducedForElement(@NotNull final PsiElement element) {
|
||||
// test_functions.py and test_foo do not contain any TestCase and can't be launched with unittest
|
||||
final PsiFile file = element.getContainingFile();
|
||||
if (file == null) {
|
||||
return true;
|
||||
}
|
||||
final String name = file.getName();
|
||||
return !(name.endsWith("test_functions.py") || name.endsWith("test_foo.py"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,24 +841,6 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleCases() {
|
||||
runPythonTest(
|
||||
new CreateConfigurationMultipleCasesTask<PyUnitTestConfiguration>(PythonTestConfigurationsModel.PYTHONS_UNITTEST_NAME,
|
||||
PyUnitTestConfiguration.class) {
|
||||
@Override
|
||||
protected boolean configurationShouldBeProducedForElement(@NotNull final PsiElement element) {
|
||||
// test_functions.py and test_foo do not contain any TestCase and can't be launched with unittest
|
||||
final PsiFile file = element.getContainingFile();
|
||||
if (file == null) {
|
||||
return true;
|
||||
}
|
||||
final String name = file.getName();
|
||||
return !(name.endsWith("test_functions.py") || name.endsWith("test_foo.py"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private abstract class PyUnitTestProcessWithConsoleTestTask extends PyUnitTestLikeProcessWithConsoleTestTask<PyUnitTestProcessRunner> {
|
||||
public PyUnitTestProcessWithConsoleTestTask(@NotNull String relativePathToTestData,
|
||||
|
||||
Reference in New Issue
Block a user