ATTest removed

* Beta version does not have any updates since 2012
This commit is contained in:
Ilya.Kazakevich
2017-02-01 16:23:01 +03:00
parent f2983d7c83
commit dec4bc1bba
16 changed files with 3 additions and 459 deletions
@@ -203,8 +203,6 @@ public class PyNames {
public static final String NOSE_TEST = "nose";
public static final String PY_TEST = "pytest";
public static final String AT_TEST = "Attest";
public static final String AT_TEST_IMPORT = "attest";
public static final String TEST_CASE = "TestCase";
@@ -159,7 +159,6 @@
<runConfigurationProducer implementation="com.jetbrains.python.testing.doctest.PythonDocTestConfigurationProducer"/>
<runConfigurationProducer implementation="com.jetbrains.python.testing.tox.PyToxConfigurationProducer"/>
<runConfigurationProducer implementation="com.jetbrains.python.testing.nosetest.PythonNoseTestConfigurationProducer"/>
<runConfigurationProducer implementation="com.jetbrains.python.testing.attest.PythonAtTestConfigurationProducer"/>
<codeInsight.lineMarkerProvider language="Python" implementationClass="com.jetbrains.python.codeInsight.PyLineMarkerProvider"/>
<runLineMarkerContributor language="Python" implementationClass="com.jetbrains.python.codeInsight.PyRunLineMarkerContributor"/>
@@ -813,9 +813,6 @@ runcfg.pytest.target=&Target:
runcfg.pytest.parameters=&Options:
runcfg.pytest.keywords=&Keywords:
### attest run conf
runcfg.attest.display_name=Attests
runcfg.attest.description=Python's attests run configuration
### test run configuration
runcfg.test.display_name=Python tests
@@ -54,7 +54,6 @@ public enum PythonHelper implements HelperPackage {
SETUPPY("pycharm", "pycharm_setup_runner"),
NOSE("pycharm", "noserunner"),
PYTEST("pycharm", "pytestrunner"),
ATTEST("pycharm", "attestrunner"),
DOCSTRING("pycharm", "docrunner"),
BEHAVE("pycharm", "behave_runner"),
@@ -144,12 +144,6 @@ public class PyIntegratedToolsConfigurable implements SearchableConfigurable {
createQuickFix(sdk, facetErrorPanel, PyNames.NOSE_TEST));
}
}
else if (PythonTestConfigurationsModel.PYTHONS_ATTEST_NAME.equals(selectedItem)) {
if (!VFSTestFrameworkListener.getInstance().isAtTestInstalled(sdk)) {
return new ValidationResult(PyBundle.message("runcfg.testing.no.test.framework", "attest"),
createQuickFix(sdk, facetErrorPanel, PyNames.AT_TEST));
}
}
}
return ValidationResult.OK;
}
@@ -119,13 +119,10 @@ public class PyIntegratedToolsProjectConfigurator implements DirectoryProjectCon
if (packages != null) {
final boolean nose = PyPackageUtil.findPackage(packages, PyNames.NOSE_TEST) != null;
final boolean pytest = PyPackageUtil.findPackage(packages, PyNames.PY_TEST) != null;
final boolean attest = PyPackageUtil.findPackage(packages, PyNames.AT_TEST) != null;
if (nose)
testRunner = PythonTestConfigurationsModel.PYTHONS_NOSETEST_NAME;
else if (pytest)
testRunner = PythonTestConfigurationsModel.PY_TEST_NAME;
else if (attest)
testRunner = PythonTestConfigurationsModel.PYTHONS_ATTEST_NAME;
if (!testRunner.isEmpty()) {
LOG.debug("Test runner '" + testRunner + "' was detected from SDK " + sdk);
}
@@ -166,9 +163,6 @@ public class PyIntegratedToolsProjectConfigurator implements DirectoryProjectCon
if (stringValue.contains(PyNames.PY_TEST)) {
return PythonTestConfigurationsModel.PY_TEST_NAME;
}
if (stringValue.contains(PyNames.AT_TEST_IMPORT)) {
return PythonTestConfigurationsModel.PYTHONS_ATTEST_NAME;
}
}
}
return "";
@@ -211,9 +205,6 @@ public class PyIntegratedToolsProjectConfigurator implements DirectoryProjectCon
if (PyNames.PY_TEST.equals(importElement.getVisibleName())) {
return PythonTestConfigurationsModel.PY_TEST_NAME;
}
if (PyNames.AT_TEST_IMPORT.equals(importElement.getVisibleName())) {
return PythonTestConfigurationsModel.PYTHONS_ATTEST_NAME;
}
}
}
return "";
@@ -22,7 +22,6 @@ import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.project.Project;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.run.PythonConfigurationFactoryBase;
import com.jetbrains.python.testing.attest.PythonAtTestRunConfiguration;
import com.jetbrains.python.testing.doctest.PythonDocTestRunConfiguration;
import com.jetbrains.python.testing.nosetest.PythonNoseTestRunConfiguration;
import com.jetbrains.python.testing.pytest.PyTestRunConfiguration;
@@ -42,7 +41,6 @@ public class PythonTestConfigurationType implements ConfigurationType {
public final PythonUnitTestConfigurationFactory PY_UNITTEST_FACTORY = new PythonUnitTestConfigurationFactory(this);
public final PythonNoseTestConfigurationFactory PY_NOSETEST_FACTORY = new PythonNoseTestConfigurationFactory(this);
public final PythonPyTestConfigurationFactory PY_PYTEST_FACTORY = new PythonPyTestConfigurationFactory(this);
public final PythonAtTestConfigurationFactory PY_ATTEST_FACTORY = new PythonAtTestConfigurationFactory(this);
public static PythonTestConfigurationType getInstance() {
return ConfigurationTypeUtil.findConfigurationType(PythonTestConfigurationType.class);
@@ -112,22 +110,6 @@ public class PythonTestConfigurationType implements ConfigurationType {
}
}
private static class PythonAtTestConfigurationFactory extends PythonConfigurationFactoryBase {
protected PythonAtTestConfigurationFactory(ConfigurationType configurationType) {
super(configurationType);
}
@Override
public RunConfiguration createTemplateConfiguration(Project project) {
return new PythonAtTestRunConfiguration(project, this);
}
@Override
public String getName() {
return PyBundle.message("runcfg.attest.display_name");
}
}
@Override
public String getDisplayName() {
return PyBundle.message("runcfg.test.display_name");
@@ -152,6 +134,6 @@ public class PythonTestConfigurationType implements ConfigurationType {
@Override
public ConfigurationFactory[] getConfigurationFactories() {
return new ConfigurationFactory[] {PY_UNITTEST_FACTORY, PY_DOCTEST_FACTORY, PY_NOSETEST_FACTORY,
PY_PYTEST_FACTORY, PY_ATTEST_FACTORY};
PY_PYTEST_FACTORY};
}
}
@@ -30,7 +30,6 @@ public class PythonTestConfigurationsModel extends CollectionComboBoxModel {
public static final String PYTHONS_UNITTEST_NAME = PyBundle.message("runcfg.unittest.display_name");
public static final String PYTHONS_NOSETEST_NAME = PyBundle.message("runcfg.nosetests.display_name");
public static final String PY_TEST_NAME = PyBundle.message("runcfg.pytest.display_name");
public static final String PYTHONS_ATTEST_NAME = PyBundle.message("runcfg.attest.display_name");
private String myTestRunner;
private Module myModule;
@@ -37,7 +37,6 @@ public class TestRunnerService implements PersistentStateComponent<TestRunnerSer
myConfigurations.add(PythonTestConfigurationsModel.PYTHONS_UNITTEST_NAME);
myConfigurations.add(PythonTestConfigurationsModel.PYTHONS_NOSETEST_NAME);
myConfigurations.add(PythonTestConfigurationsModel.PY_TEST_NAME);
myConfigurations.add(PythonTestConfigurationsModel.PYTHONS_ATTEST_NAME);
}
public List<String> getConfigurations() {
@@ -73,8 +73,7 @@ public class VFSTestFrameworkListener {
final String path = event.getPath();
final boolean containsNose = path.contains(PyNames.NOSE_TEST);
final boolean containsPy = path.contains("py-1") || path.contains(PyNames.PY_TEST);
final boolean containsAt = path.contains(PyNames.AT_TEST);
if (!containsAt && !containsNose && !containsPy) continue;
if (!containsNose && !containsPy) continue;
for (Sdk sdk : PythonSdkType.getAllSdks()) {
if (PySdkUtil.isRemote(sdk)) {
continue;
@@ -90,10 +89,6 @@ public class VFSTestFrameworkListener {
scheduleTestFrameworkCheck(sdk, PyNames.PY_TEST);
return;
}
else {
scheduleTestFrameworkCheck(sdk, PyNames.AT_TEST);
return;
}
}
}
}
@@ -104,7 +99,7 @@ public class VFSTestFrameworkListener {
}
public void updateAllTestFrameworks(@NotNull Sdk sdk) {
final Map<String, Boolean> whichInstalled = checkTestFrameworksInstalled(sdk, PyNames.PY_TEST, PyNames.NOSE_TEST, PyNames.AT_TEST);
final Map<String, Boolean> whichInstalled = checkTestFrameworksInstalled(sdk, PyNames.PY_TEST, PyNames.NOSE_TEST);
ApplicationManager.getApplication().invokeLater(() -> {
for (Map.Entry<String, Boolean> entry : whichInstalled.entrySet()) {
final Boolean installed = entry.getValue();
@@ -191,14 +186,6 @@ public class VFSTestFrameworkListener {
myService.SDK_TO_ATTEST.put(sdkHome, installed);
}
public boolean isAtTestInstalled(@NotNull Sdk sdk) {
final Boolean isInstalled = myService.SDK_TO_ATTEST.get(sdk.getHomePath());
if (isInstalled == null) {
scheduleTestFrameworkCheck(sdk, PyNames.AT_TEST);
return true;
}
return isInstalled;
}
public void setTestFrameworkInstalled(boolean installed, @NotNull String sdkHome, @NotNull String name) {
switch (name) {
@@ -208,9 +195,6 @@ public class VFSTestFrameworkListener {
case PyNames.PY_TEST:
setPyTestInstalled(installed, sdkHome);
break;
case PyNames.AT_TEST:
setAtTestInstalled(installed, sdkHome);
break;
}
}
}
@@ -1,76 +0,0 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jetbrains.python.testing.attest;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.util.io.FileUtil;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.testing.PythonTestCommandLineStateBase;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* User: catherine
*/
public class PythonAtTestCommandLineState extends PythonTestCommandLineStateBase {
private final PythonAtTestRunConfiguration myConfig;
public PythonAtTestCommandLineState(PythonAtTestRunConfiguration runConfiguration, ExecutionEnvironment env) {
super(runConfiguration, env);
myConfig = runConfiguration;
}
@Override
protected PythonHelper getRunner() {
return PythonHelper.ATTEST;
}
@NotNull
protected List<String> getTestSpecs() {
List<String> specs = new ArrayList<>();
final String scriptName = FileUtil.toSystemDependentName(myConfig.getScriptName());
switch (myConfig.getTestType()) {
case TEST_SCRIPT:
specs.add(scriptName);
break;
case TEST_CLASS:
specs.add(scriptName + "::" + myConfig.getClassName());
break;
case TEST_METHOD:
specs.add(scriptName + "::" + myConfig.getClassName() + "::" + myConfig.getMethodName());
break;
case TEST_FOLDER:
final String folderName = FileUtil.toSystemDependentName(myConfig.getFolderName() + "/");
if (!myConfig.getPattern().isEmpty()) {
specs.add(folderName + ";" + myConfig.getPattern());
}
else
specs.add(folderName);
break;
case TEST_FUNCTION:
specs.add(scriptName + "::::" + myConfig.getMethodName());
break;
default:
throw new IllegalArgumentException("Unknown test type: " + myConfig.getTestType());
}
return specs;
}
}
@@ -1,103 +0,0 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jetbrains.python.testing.attest;
import com.google.common.collect.Lists;
import com.intellij.execution.Location;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.psi.PsiElement;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.types.PyClassLikeType;
import com.jetbrains.python.psi.types.TypeEvalContext;
import com.jetbrains.python.sdk.PythonSdkType;
import com.jetbrains.python.testing.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* User: catherine
*/
public class PythonAtTestConfigurationProducer extends
PythonTestConfigurationProducer {
public PythonAtTestConfigurationProducer() {
super(PythonTestConfigurationType.getInstance().PY_ATTEST_FACTORY);
}
protected boolean isAvailable(@NotNull final Location location) {
final PsiElement element = location.getPsiElement();
Module module = location.getModule();
if (module == null) module = ModuleUtilCore.findModuleForPsiElement(element);
final Sdk sdk = PythonSdkType.findPythonSdk(module);
return module != null && TestRunnerService.getInstance(module).getProjectConfiguration().equals(
PythonTestConfigurationsModel.PYTHONS_ATTEST_NAME) && sdk != null;
}
@Override
protected boolean isTestClass(@NotNull final PyClass pyClass,
@Nullable final AbstractPythonTestRunConfiguration configuration,
@Nullable final TypeEvalContext context) {
for (PyClassLikeType type : pyClass.getAncestorTypes(TypeEvalContext.codeInsightFallback(pyClass.getProject()))) {
if (type != null && "TestBase".equals(type.getName()) && hasTestFunction(pyClass)) {
return true;
}
}
return false;
}
private static boolean hasTestFunction(@NotNull final PyClass pyClass) {
PyFunction[] methods = pyClass.getMethods();
for (PyFunction function : methods) {
PyDecoratorList decorators = function.getDecoratorList();
if (decorators == null) continue;
for (PyDecorator decorator : decorators.getDecorators()) {
if ("test".equals(decorator.getName()) || "test_if".equals(decorator.getName()))
return true;
}
}
return false;
}
protected boolean isTestFunction(@NotNull final PyFunction pyFunction,
@Nullable final AbstractPythonTestRunConfiguration configuration) {
PyDecoratorList decorators = pyFunction.getDecoratorList();
if (decorators == null) return false;
for (PyDecorator decorator : decorators.getDecorators()) {
if ("test".equals(decorator.getName()) || "test_if".equals(decorator.getName()))
return true;
}
return false;
}
protected List<PyStatement> getTestCaseClassesFromFile(@NotNull final PyFile file) {
List<PyStatement> result = Lists.newArrayList();
for (PyClass cls : file.getTopLevelClasses()) {
if (isTestClass(cls, null, null)) {
result.add(cls);
}
}
for (PyFunction cls : file.getTopLevelFunctions()) {
if (isTestFunction(cls, null)) {
result.add(cls);
}
}
return result;
}
}
@@ -1,87 +0,0 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jetbrains.python.testing.attest;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.*;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.sdk.PythonSdkType;
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration;
import com.jetbrains.python.testing.VFSTestFrameworkListener;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
/**
* User: catherine
*/
public class PythonAtTestRunConfiguration extends AbstractPythonTestRunConfiguration<PythonAtTestRunConfiguration>
implements PythonAtTestRunConfigurationParams {
protected String myTitle = "Attest";
protected String myPluralTitle = "Attests";
public PythonAtTestRunConfiguration(Project project,
ConfigurationFactory configurationFactory) {
super(project, configurationFactory);
}
@Override
protected SettingsEditor<PythonAtTestRunConfiguration> createConfigurationEditor() {
return new PythonAtTestRunConfigurationEditor(getProject(), this);
}
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
return new PythonAtTestCommandLineState(this, env);
}
@Override
public void readExternal(Element element) throws InvalidDataException {
super.readExternal(element);
}
@Override
public void writeExternal(Element element) throws WriteExternalException {
super.writeExternal(element);
}
@Override
protected String getTitle() {
return myTitle;
}
@Override
protected String getPluralTitle() {
return myPluralTitle;
}
public static void copyParams(PythonAtTestRunConfigurationParams source, PythonAtTestRunConfigurationParams target) {
copyParams(source.getTestRunConfigurationParams(), target.getTestRunConfigurationParams());
}
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
super.checkConfiguration();
Sdk sdkPath = PythonSdkType.findSdkByPath(getInterpreterPath());
if (sdkPath != null && !VFSTestFrameworkListener.getInstance().isAtTestInstalled(sdkPath))
throw new RuntimeConfigurationWarning(PyBundle.message("runcfg.testing.no.test.framework", "attest"));
}
}
@@ -1,51 +0,0 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jetbrains.python.testing.attest;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* User: catherine
*/
public class PythonAtTestRunConfigurationEditor extends SettingsEditor<PythonAtTestRunConfiguration> {
private PythonAtTestRunConfigurationForm myForm;
public PythonAtTestRunConfigurationEditor(final Project project, final PythonAtTestRunConfiguration configuration) {
myForm = new PythonAtTestRunConfigurationForm(project, configuration);
}
protected void resetEditorFrom(@NotNull final PythonAtTestRunConfiguration config) {
PythonAtTestRunConfiguration.copyParams(config, myForm);
}
protected void applyEditorTo(@NotNull final PythonAtTestRunConfiguration config) throws ConfigurationException {
PythonAtTestRunConfiguration.copyParams(myForm, config);
}
@NotNull
protected JComponent createEditor() {
return myForm.getPanel();
}
protected void disposeEditor() {
myForm = null;
}
}
@@ -1,55 +0,0 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jetbrains.python.testing.attest;
import com.intellij.openapi.project.Project;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.testing.AbstractPythonTestRunConfigurationParams;
import com.jetbrains.python.testing.PythonTestRunConfigurationForm;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
/**
* User: catherine
*/
public class PythonAtTestRunConfigurationForm implements PythonAtTestRunConfigurationParams {
private JPanel myRootPanel;
private final PythonTestRunConfigurationForm myTestRunConfigurationForm;
public PythonAtTestRunConfigurationForm(final Project project, final PythonAtTestRunConfiguration configuration) {
myRootPanel = new JPanel(new BorderLayout());
myTestRunConfigurationForm = new PythonTestRunConfigurationForm(project, configuration);
TitledBorder border = (TitledBorder)myTestRunConfigurationForm.getTestsPanel().getBorder();
border.setTitle(PyBundle.message("runcfg.attest.display_name"));
myRootPanel.add(myTestRunConfigurationForm.getPanel(), BorderLayout.CENTER);
}
@Override
public AbstractPythonTestRunConfigurationParams getTestRunConfigurationParams() {
return myTestRunConfigurationForm;
}
public JComponent getPanel() {
return myRootPanel;
}
}
@@ -1,26 +0,0 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jetbrains.python.testing.attest;
import com.jetbrains.python.testing.AbstractPythonTestRunConfigurationParams;
/**
* User: catherine
*/
public interface PythonAtTestRunConfigurationParams {
AbstractPythonTestRunConfigurationParams getTestRunConfigurationParams();
}