2 * Copyright 2000-2014 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.jetbrains.python.testing.nosetest;
18 import com.intellij.execution.Location;
19 import com.intellij.openapi.module.Module;
20 import com.intellij.openapi.module.ModuleManager;
21 import com.intellij.openapi.projectRoots.Sdk;
22 import com.intellij.psi.PsiElement;
23 import com.jetbrains.python.psi.PyFunction;
24 import com.jetbrains.python.sdk.PythonSdkType;
25 import com.jetbrains.python.testing.*;
26 import org.jetbrains.annotations.NotNull;
27 import org.jetbrains.annotations.Nullable;
29 public class PythonNoseTestConfigurationProducer extends
30 PythonTestConfigurationProducer {
31 public PythonNoseTestConfigurationProducer() {
32 super(PythonTestConfigurationType.getInstance().PY_NOSETEST_FACTORY);
35 protected boolean isAvailable(@NotNull final Location location) {
36 final PsiElement element = location.getPsiElement();
37 Module module = location.getModule();
39 final Module[] modules = ModuleManager.getInstance(element.getProject()).getModules();
40 if (modules.length == 0) return false;
43 final Sdk sdk = PythonSdkType.findPythonSdk(module);
44 return (PythonTestConfigurationsModel.PYTHONS_NOSETEST_NAME.equals(TestRunnerService.getInstance(module).getProjectConfiguration()) && sdk != null);
48 protected boolean isTestFunction(@NotNull final PyFunction pyFunction, @Nullable final AbstractPythonTestRunConfiguration configuration) {
49 return PythonUnitTestUtil.isTestCaseFunction(pyFunction, true);