mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
New python test runners API based on Leonid s TC runners
* Fixing according to review:/IDEA-CR-17341
This commit is contained in:
@@ -36,7 +36,7 @@ messages.TeamcityServiceMessages.message = __jb_message
|
||||
def jb_patch_separator(targets, fs_glue, python_glue, fs_to_python_glue):
|
||||
"""
|
||||
Targets are always dot separated according to manual.
|
||||
How ever, some runners may need different separators.
|
||||
However, some runners may need different separators.
|
||||
This function splits target to file/symbol parts and glues them using provided glues.
|
||||
|
||||
:param targets: list of dot-separated targets
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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;
|
||||
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
* Descriptor to choose only .py files and (probably) folders.
|
||||
* @author Ilya.Kazakevich
|
||||
*/
|
||||
public final class PyFileChooserDescriptor extends FileChooserDescriptor {
|
||||
public PyFileChooserDescriptor(final boolean chooseFolders) {super(true, chooseFolders, false, false, false, false);}
|
||||
|
||||
@Override
|
||||
public boolean isFileVisible(final VirtualFile file, final boolean showHiddenFiles) {
|
||||
return file.isDirectory() || file.getExtension() == null || Comparing.equal(file.getExtension(), "py");
|
||||
}
|
||||
}
|
||||
@@ -49,18 +49,18 @@ public enum PythonHelper implements HelperPackage {
|
||||
LOAD_ENTRY_POINT("pycharm", "pycharm_load_entry_point"),
|
||||
|
||||
// Test runners
|
||||
UT("pycharm", "utrunner"),
|
||||
UT_OLD("pycharm", "utrunner"),
|
||||
TOX("pycharm", "_jb_tox_runner"),
|
||||
SETUPPY("pycharm", "pycharm_setup_runner"),
|
||||
NOSE("pycharm", "noserunner"),
|
||||
PYTEST("pycharm", "pytestrunner"),
|
||||
NOSE_OLD("pycharm", "noserunner"),
|
||||
PYTEST_OLD("pycharm", "pytestrunner"),
|
||||
DOCSTRING("pycharm", "docrunner"),
|
||||
|
||||
// Runners for new test runner API.
|
||||
|
||||
UNIVERSAL_UT("pycharm", "_jb_unittest_runner"),
|
||||
UNIVERSAL_PYTEST("pycharm", "_jb_pytest_runner"),
|
||||
UNIVERSAL_NOSE("pycharm", "_jb_nosetest_runner"),
|
||||
UNITTEST("pycharm", "_jb_unittest_runner"),
|
||||
PYTEST("pycharm", "_jb_pytest_runner"),
|
||||
NOSE("pycharm", "_jb_nosetest_runner"),
|
||||
|
||||
BEHAVE("pycharm", "behave_runner"),
|
||||
LETTUCE("pycharm", "lettuce_runner"),
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.intellij.ui.PanelWithAnchor;
|
||||
import com.intellij.ui.RawCommandLineEditor;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.jetbrains.python.PyFileChooserDescriptor;
|
||||
import com.jetbrains.python.debugger.PyDebuggerOptionsProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -58,7 +57,12 @@ public class PythonRunConfigurationForm implements PythonRunConfigurationParams,
|
||||
|
||||
myProject = configuration.getProject();
|
||||
|
||||
FileChooserDescriptor chooserDescriptor = new PyFileChooserDescriptor(false);
|
||||
FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
|
||||
@Override
|
||||
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
|
||||
return file.isDirectory() || file.getExtension() == null || Comparing.equal(file.getExtension(), "py");
|
||||
}
|
||||
};
|
||||
//chooserDescriptor.setRoot(s.getProject().getBaseDir());
|
||||
|
||||
ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener =
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class PythonNoseTestCommandLineState extends PythonTestCommandLineStateBa
|
||||
|
||||
@Override
|
||||
protected PythonHelper getRunner() {
|
||||
return PythonHelper.NOSE;
|
||||
return PythonHelper.NOSE_OLD;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -52,7 +52,7 @@ public class PyTestCommandLineState extends PythonTestCommandLineStateBase {
|
||||
|
||||
@Override
|
||||
protected HelperPackage getRunner() {
|
||||
return PythonHelper.PYTEST;
|
||||
return PythonHelper.PYTEST_OLD;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class PythonUnitTestCommandLineState extends PythonTestCommandLineStateBa
|
||||
if (myConfig.getTestType() == AbstractPythonOldTestRunConfiguration.TestType.TEST_SCRIPT &&
|
||||
myConfig.getScriptName().endsWith(PyNames.SETUP_DOT_PY))
|
||||
return PythonHelper.SETUPPY;
|
||||
return PythonHelper.UT;
|
||||
return PythonHelper.UT_OLD;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -34,7 +34,7 @@ class PyUniversalNoseTestSettingsEditor(configuration: PyUniversalTestConfigurat
|
||||
|
||||
class PyUniversalNoseTestExecutionEnvironment(configuration: PyUniversalNoseTestConfiguration, environment: ExecutionEnvironment) :
|
||||
PyUniversalTestExecutionEnvironment<PyUniversalNoseTestConfiguration>(configuration, environment) {
|
||||
override fun getRunner() = PythonHelper.UNIVERSAL_NOSE
|
||||
override fun getRunner() = PythonHelper.NOSE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class PyUniversalPyTestSettingsEditor(configuration: PyUniversalTestConfiguratio
|
||||
|
||||
class PyUniversalPyTestExecutionEnvironment(configuration: PyUniversalPyTestConfiguration, environment: ExecutionEnvironment) :
|
||||
PyUniversalTestExecutionEnvironment<PyUniversalPyTestConfiguration>(configuration, environment) {
|
||||
override fun getRunner() = PythonHelper.UNIVERSAL_PYTEST
|
||||
override fun getRunner() = PythonHelper.PYTEST
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.jetbrains.python.testing.universalTests;
|
||||
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
@@ -23,7 +25,7 @@ import com.intellij.ui.components.JBTextField;
|
||||
import com.intellij.uiDesigner.core.GridConstraints;
|
||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.jetbrains.python.PyFileChooserDescriptor;
|
||||
import com.jetbrains.python.PythonFileType;
|
||||
import com.jetbrains.python.run.AbstractPyCommonOptionsForm;
|
||||
import com.jetbrains.python.run.PyCommonOptionsFormFactory;
|
||||
import com.jetbrains.reflection.ReflectionUtilsKt;
|
||||
@@ -106,8 +108,9 @@ public final class PyUniversalTestForm implements SimplePropertiesProvider {
|
||||
|
||||
|
||||
final PyUniversalTestForm form = new PyUniversalTestForm();
|
||||
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(PythonFileType.INSTANCE);
|
||||
form.myTargetText.addBrowseFolderListener("Choose File or Folder", null, configuration.getProject(),
|
||||
new PyFileChooserDescriptor(true));
|
||||
descriptor);
|
||||
|
||||
for (final TestTargetType testTargetType : TestTargetType.values()) {
|
||||
final JBRadioButton button = new JBRadioButton(StringUtil.capitalize(testTargetType.name().toLowerCase(Locale.getDefault())));
|
||||
|
||||
@@ -286,7 +286,7 @@ abstract class PyUniversalTestConfiguration(project: Project,
|
||||
}
|
||||
|
||||
|
||||
private fun getConfigFields() = getProperties(this, ConfigField::class)
|
||||
private fun getConfigFields() = getProperties(this, ConfigField::class.java)
|
||||
|
||||
/**
|
||||
* Checks if element could be test target for this config.
|
||||
|
||||
@@ -34,7 +34,7 @@ class PyUniversalUnitTestSettingsEditor(configuration: PyUniversalTestConfigurat
|
||||
|
||||
class PyUniversalUnitTestExecutionEnvironment(configuration: PyUniversalUnitTestConfiguration, environment: ExecutionEnvironment) :
|
||||
PyUniversalTestExecutionEnvironment<PyUniversalUnitTestConfiguration>(configuration, environment) {
|
||||
override fun getRunner() = PythonHelper.UNIVERSAL_UT
|
||||
override fun getRunner() = PythonHelper.UNITTEST
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -100,11 +100,12 @@ private fun KProperty<*>.isAnnotated(annotation: KClass<*>): Boolean {
|
||||
|
||||
/**
|
||||
* @param instance object with properties (see module doc)
|
||||
* @param annotationToFilterBy optional annotation class to fetch only kotlin properties annotated with it. Only supported in Kotlin
|
||||
* @param annotationToFilterByClass optional annotation class to fetch only kotlin properties annotated with it. Only supported in Kotlin
|
||||
* @param usePojoProperties search for java-style properties (kotlin otherwise)
|
||||
* @return properties of some object
|
||||
*/
|
||||
fun getProperties(instance: Any, annotationToFilterBy: KClass<*>? = null, usePojoProperties: Boolean = false): Properties {
|
||||
fun getProperties(instance: Any, annotationToFilterByClass: Class<*>? = null, usePojoProperties: Boolean = false): Properties {
|
||||
val annotationToFilterBy = annotationToFilterByClass?.kotlin
|
||||
|
||||
if (usePojoProperties) {
|
||||
// Java props
|
||||
@@ -121,7 +122,7 @@ fun getProperties(instance: Any, annotationToFilterBy: KClass<*>? = null, usePoj
|
||||
allKotlinProperties.filter { it.isAnnotated(DelegationProperty::class) }.forEach {
|
||||
val delegatedInstance = it.getter.call(instance)
|
||||
if (delegatedInstance != null) {
|
||||
delegatedProperties = getProperties(delegatedInstance, annotationToFilterBy, false).properties
|
||||
delegatedProperties = getProperties(delegatedInstance, annotationToFilterBy?.java, false).properties
|
||||
allKotlinProperties.remove(it)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user