本文整理汇总了Java中com.jetbrains.python.testing.AbstractPythonTestRunConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java AbstractPythonTestRunConfiguration类的具体用法?Java AbstractPythonTestRunConfiguration怎么用?Java AbstractPythonTestRunConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractPythonTestRunConfiguration类属于com.jetbrains.python.testing包,在下文中一共展示了AbstractPythonTestRunConfiguration类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTestSpec
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
/**
* Given a "normal" run config, transform it into a test spec (something that could be passed
* to tools/runtests.py) that does the equivalent thing.
*
* @param configuration the proposed configuration normally computed by PyCharm.
* @param basePath the root directory of the current project.
* @throws IllegalStateException if the test is not in the current project.
*/
private String getTestSpec(AbstractPythonTestRunConfiguration configuration, String basePath) {
AbstractPythonTestRunConfiguration.TestType testType = configuration.getTestType();
switch (testType) {
case TEST_FOLDER:
return getPathSpec(configuration.getFolderName(), basePath);
case TEST_SCRIPT:
return getPathSpec(configuration.getScriptName(), basePath);
case TEST_CLASS:
return getPathSpec(configuration.getScriptName(), basePath) +
"." + configuration.getClassName();
case TEST_METHOD:
return getPathSpec(configuration.getScriptName(), basePath) +
"." + configuration.getClassName() + "." + configuration.getMethodName();
case TEST_FUNCTION:
return getPathSpec(configuration.getScriptName(), basePath) +
"." + configuration.getMethodName();
default:
throw new IllegalArgumentException("Unexpected test type: " + testType);
}
}
示例2: getRunner
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
@Override
protected PythonHelper getRunner() {
if (myConfig.getTestType() == AbstractPythonTestRunConfiguration.TestType.TEST_SCRIPT &&
myConfig.getScriptName().endsWith(PyNames.SETUP_DOT_PY))
return PythonHelper.SETUPPY;
return PythonHelper.UT;
}
示例3: runConfiguration
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
protected void runConfiguration(ConfigurationFactory factory, String sdkHome, final Project project) throws Exception {
final RunnerAndConfigurationSettings settings =
RunManager.getInstance(project).createRunConfiguration("test", factory);
AbstractPythonTestRunConfiguration config = (AbstractPythonTestRunConfiguration)settings.getConfiguration();
config.setSdkHome(sdkHome);
config.setScriptName(getScriptPath());
config.setWorkingDirectory(getWorkingFolder());
PythonSdkFlavor sdk = PythonSdkFlavor.getFlavor(sdkHome);
if (sdk instanceof JythonSdkFlavor) {
config.setInterpreterOptions(JythonSdkFlavor.getPythonPathCmdLineArgument(Lists.<String>newArrayList(getWorkingFolder())));
}
else {
PythonEnvUtil.addToPythonPath(config.getEnvs(), getWorkingFolder());
}
configure(config);
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
RunManagerEx.getInstanceEx(project).addConfiguration(settings, false);
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(settings);
Assert.assertSame(settings, RunManagerEx.getInstanceEx(project).getSelectedConfiguration());
}
}.execute();
runConfiguration(settings, config);
}
示例4: isConfigurationFromContext
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
/**
* Decide whether the given pre-existing run config matches the current code point (to avoid
* generating a new run config for every test we run). Instead of implementing separate logic
* based on the code structure, just generate another config and see if the test spec matches
* up.
*/
@Override
public boolean isConfigurationFromContext(
AbstractPythonTestRunConfiguration configuration, ConfigurationContext context) {
PythonUnitTestRunConfiguration newConfig = (PythonUnitTestRunConfiguration)
cloneTemplateConfiguration(context).getConfiguration();
setupConfigurationFromContext(newConfig, context, null);
return configuration.getScriptName().equals(newConfig.getScriptName()) &&
configuration.getEnvs().equals(newConfig.getEnvs());
}
示例5: isTestFunction
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
@Override
protected boolean isTestFunction(@NotNull final PyFunction pyFunction, @Nullable final AbstractPythonTestRunConfiguration configuration) {
return PythonDocTestUtil.isDocTestFunction(pyFunction);
}
示例6: isTestClass
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
@Override
protected boolean isTestClass(@NotNull PyClass pyClass, @Nullable final AbstractPythonTestRunConfiguration configuration) {
return PythonDocTestUtil.isDocTestClass(pyClass);
}
示例7: copyParams
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
public static void copyParams(PythonNoseTestRunConfigurationParams source, PythonNoseTestRunConfigurationParams target) {
AbstractPythonTestRunConfiguration.copyParams(source.getTestRunConfigurationParams(), target.getTestRunConfigurationParams());
target.setParams(source.getParams());
target.useParam(source.useParam());
}
示例8: configure
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
protected void configure(AbstractPythonTestRunConfiguration config) {
}
示例9: setupConfigurationFromContext
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
/**
* Given a context (e.g. a location in source code), determine if a run
* configuration can be generated here. If not, return false. If so, fill in
* the configuration param with the proper values.
*/
@Override
protected boolean setupConfigurationFromContext(
AbstractPythonTestRunConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
// Disable other Unittest menu items; see the isAvailable javadoc.
Module module = context.getModule();
if (module == null) {
return false;
}
TestRunnerService.getInstance(module).setProjectConfiguration("KAUnittests");
boolean result = super.setupConfigurationFromContext(
configuration, context, sourceElement);
if (!result) {
return false;
}
// TODO(alan): For test methods, the normal PyCharm code is smart enough to exclude the
// class name in the menu item (see AbstractPythonTestRunConfiguration.getActionName ), but
// that logic doesn't work in our case since we switch out the test type (and also probably
// because we set the name as modified). Probably the right way to solve this is to create
// a separate run config class for KA tests.
configuration.setName(configuration.getName().replaceFirst("Unittest", "KA Test"));
configuration.setNameChangedByUser(true);
String basePath = context.getProject().getBasePath();
String testSpec;
try {
testSpec = getTestSpec(configuration, basePath);
} catch (IllegalStateException e) {
// Swallow and fail: the file was outside of the project.
return false;
}
configuration.setTestType(AbstractPythonTestRunConfiguration.TestType.TEST_SCRIPT);
configuration.setScriptName(basePath + "/tools/load_tests.py");
configuration.setEnvs(ImmutableMap.of("TEST_SPECS", testSpec, "MAX_TEST_SIZE", "huge"));
configuration.setWorkingDirectory(basePath);
return true;
}