當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。