mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-8427 Behave BDD support
PY-4186 Lettuce BDD tool support Cofiguration producers added
This commit is contained in:
+22
-5
@@ -19,9 +19,11 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.UIBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FileChooserDescriptorFactory {
|
||||
private FileChooserDescriptorFactory() { }
|
||||
private FileChooserDescriptorFactory() {
|
||||
}
|
||||
|
||||
public static FileChooserDescriptor createAllButJarContentsDescriptor() {
|
||||
return new FileChooserDescriptor(true, true, true, true, false, true);
|
||||
@@ -83,7 +85,18 @@ public class FileChooserDescriptorFactory {
|
||||
}
|
||||
|
||||
public static FileChooserDescriptor createSingleFileDescriptor(final FileType fileType) {
|
||||
return new FileChooserDescriptor(true, false, false, false, false, false) {
|
||||
return createSingleFileDescriptor(fileType, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates file descriptor with certain type and (possible) folders.
|
||||
* @param fileType supported type
|
||||
* @param supportDirectories support directories or not
|
||||
* @return descriptor
|
||||
*/
|
||||
@NotNull
|
||||
public static FileChooserDescriptor createSingleFileDescriptor(final FileType fileType, final boolean supportDirectories) {
|
||||
return new FileChooserDescriptor(true, supportDirectories, false, false, false, false) {
|
||||
@Override
|
||||
public boolean isFileVisible(final VirtualFile file, final boolean showHiddenFiles) {
|
||||
return file.isDirectory() || file.getFileType() == fileType;
|
||||
@@ -91,18 +104,22 @@ public class FileChooserDescriptorFactory {
|
||||
|
||||
@Override
|
||||
public boolean isFileSelectable(final VirtualFile file) {
|
||||
return super.isFileSelectable(file) && file.getFileType() == fileType;
|
||||
return super.isFileSelectable(file) && (file.getFileType() == fileType || ((file.isDirectory() && supportDirectories)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #createSingleFileNoJarsDescriptor()} (to be removed in IDEA 15) */
|
||||
/**
|
||||
* @deprecated use {@link #createSingleFileNoJarsDescriptor()} (to be removed in IDEA 15)
|
||||
*/
|
||||
@SuppressWarnings({"UnusedDeclaration", "deprecation"})
|
||||
public static FileChooserDescriptorBuilder onlyFiles() {
|
||||
return FileChooserDescriptorBuilder.onlyFiles();
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #createSingleFileOrFolderDescriptor()} ()} (to be removed in IDEA 15) */
|
||||
/**
|
||||
* @deprecated use {@link #createSingleFileOrFolderDescriptor()} ()} (to be removed in IDEA 15)
|
||||
*/
|
||||
@SuppressWarnings({"UnusedDeclaration", "deprecation"})
|
||||
public static FileChooserDescriptorBuilder filesAndFolders() {
|
||||
return FileChooserDescriptorBuilder.filesAndFolders();
|
||||
|
||||
@@ -69,6 +69,17 @@ class BddRunner(object):
|
||||
"""
|
||||
return "file:///{}/{}:{}".format(self.__base_dir, location.file, location.line)
|
||||
|
||||
def _test_undefined(self, test_name, location):
|
||||
"""
|
||||
Mark test as undefined
|
||||
:param test_name: name of test
|
||||
:type test_name str
|
||||
:param location its location
|
||||
|
||||
"""
|
||||
self._test_started(test_name, location)
|
||||
self._test_failed(test_name, message="Test undefined", details="Please define test")
|
||||
|
||||
def _test_failed(self, name, message, details):
|
||||
"""
|
||||
Report test failure
|
||||
|
||||
@@ -11,7 +11,7 @@ import os
|
||||
import traceback
|
||||
|
||||
from behave.formatter.base import Formatter
|
||||
from behave.model import Step, ScenarioOutline, Feature
|
||||
from behave.model import Step, ScenarioOutline, Feature, Scenario
|
||||
|
||||
import _bdd_utils
|
||||
|
||||
@@ -120,6 +120,16 @@ class _BehaveRunner(_bdd_utils.BddRunner):
|
||||
BddRunner for behave
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def __fix_location(element):
|
||||
"""
|
||||
Adds "filename" alias to "file" to preserve _bdd_utils contract
|
||||
:param element: location
|
||||
:return: fixed location
|
||||
"""
|
||||
element.location.file = element.location.filename
|
||||
return element
|
||||
|
||||
def __process_hook(self, is_started, context, element):
|
||||
"""
|
||||
Hook to be installed. Reports steps, features etc.
|
||||
@@ -129,7 +139,7 @@ class _BehaveRunner(_bdd_utils.BddRunner):
|
||||
:type context behave.runner.Context
|
||||
:param element feature/suite/step
|
||||
"""
|
||||
element.location.file = element.location.filename # To preserve _bdd_utils contract
|
||||
_BehaveRunner.__fix_location(element) # To preserve _bdd_utils contract
|
||||
if isinstance(element, Step):
|
||||
# Process step
|
||||
if is_started:
|
||||
@@ -140,6 +150,13 @@ class _BehaveRunner(_bdd_utils.BddRunner):
|
||||
self._test_failed(element.name, element.error_message, traceback.format_exc())
|
||||
else:
|
||||
self.tc_messages.testIgnored(element.name, "Skipped with status: {}".format(element.status))
|
||||
elif not is_started and isinstance(element, Scenario) and element.status == 'failed':
|
||||
# To process scenarios with undefined tests
|
||||
# TODO: refactor
|
||||
for step in [s for s in element.steps if s.status == 'undefined']:
|
||||
assert isinstance(step, Step), step
|
||||
self._test_undefined(step.name, _BehaveRunner.__fix_location(step).location)
|
||||
self._feature_or_scenario(is_started, element.name, element.location)
|
||||
elif isinstance(element, ScenarioOutline):
|
||||
self._feature_or_scenario(is_started, str(element.examples), element.location)
|
||||
else:
|
||||
|
||||
@@ -59,6 +59,8 @@ class _LettuceRunner(_bdd_utils.BddRunner):
|
||||
reason = step.why
|
||||
assert isinstance(reason, ReasonToFail), reason
|
||||
self._test_failed(test_name, message=reason.exception, details=reason.traceback)
|
||||
else:
|
||||
self._test_undefined(test_name, step.described_at)
|
||||
|
||||
def __install_hooks(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user