当前位置: 首页>>代码示例>>Java>>正文


Java AbstractPythonTestRunConfiguration类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Khan,项目名称:ka-pycharm-plugin,代码行数:29,代码来源:KATestConfigurationProducer.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:PythonUnitTestCommandLineState.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:PyUnitTestTask.java

示例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());
}
 
开发者ID:Khan,项目名称:ka-pycharm-plugin,代码行数:16,代码来源:KATestConfigurationProducer.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:PythonDocTestConfigurationProducer.java

示例6: isTestClass

import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
@Override
protected boolean isTestClass(@NotNull PyClass pyClass, @Nullable final AbstractPythonTestRunConfiguration configuration) {
  return PythonDocTestUtil.isDocTestClass(pyClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:PythonDocTestConfigurationProducer.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:PythonNoseTestRunConfiguration.java

示例8: configure

import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration; //导入依赖的package包/类
protected void configure(AbstractPythonTestRunConfiguration config) {
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:3,代码来源:PyUnitTestTask.java

示例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;
}
 
开发者ID:Khan,项目名称:ka-pycharm-plugin,代码行数:46,代码来源:KATestConfigurationProducer.java


注:本文中的com.jetbrains.python.testing.AbstractPythonTestRunConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。