From b5c058f522885e796e333f3a47626b8efe95e5d2 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 16 Feb 2011 11:22:39 +0300 Subject: [PATCH 1/2] fixed enabled by default test functionRB in unittests. --- .../testing/unittest/PythonUnitTestRunConfigurationForm.java | 1 + 1 file changed, 1 insertion(+) diff --git a/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestRunConfigurationForm.java b/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestRunConfigurationForm.java index ee6acfd8d88c..364b0413e364 100644 --- a/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestRunConfigurationForm.java +++ b/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestRunConfigurationForm.java @@ -28,6 +28,7 @@ public class PythonUnitTestRunConfigurationForm implements PythonUnitTestRunConf myIsPureUnittest.setSelected(configuration.isPureUnittest()); final JRadioButton functionRB = myTestRunConfigurationForm.getFunctionRB(); + functionRB.setEnabled(!myIsPureUnittest.isSelected()); myIsPureUnittest.addActionListener(new ActionListener() { @Override From 30e03efe6da428ef2d2f5512e79ba138776a2e3b Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 16 Feb 2011 11:48:24 +0300 Subject: [PATCH 2/2] fixed test run configuration producer for functions --- .../python/testing/PythonUnitTestUtil.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/python/src/com/jetbrains/python/testing/PythonUnitTestUtil.java b/python/src/com/jetbrains/python/testing/PythonUnitTestUtil.java index 7f06b18f9c56..f443547c32e8 100644 --- a/python/src/com/jetbrains/python/testing/PythonUnitTestUtil.java +++ b/python/src/com/jetbrains/python/testing/PythonUnitTestUtil.java @@ -2,6 +2,8 @@ package com.jetbrains.python.testing; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import com.intellij.psi.PsiElement; +import com.intellij.util.containers.Stack; import com.jetbrains.python.psi.*; import org.jetbrains.annotations.NotNull; @@ -60,18 +62,20 @@ public class PythonUnitTestUtil { } private static boolean hasAssertOrYield(PyStatementList list) { - for (PyStatement st : list.getStatements()) { - if (st instanceof PyAssertStatement) return true; - else if (st instanceof PyForStatement) - return hasAssertOrYield(((PyForStatement)st).getForPart().getStatementList()); - else if (st instanceof PyWhileStatement) - return hasAssertOrYield(((PyWhileStatement)st).getWhilePart().getStatementList()); - else if (st instanceof PyExpressionStatement) { - if (((PyExpressionStatement)st).getExpression() instanceof PyYieldExpression) - return true; + Stack stack = new Stack(); + if (list != null) { + for (PyStatement st : list.getStatements()) { + stack.push(st); + while (!stack.isEmpty()) { + PsiElement e = stack.pop(); + if (e instanceof PyAssertStatement || e instanceof PyYieldExpression) return true; + for (PsiElement psiElement : e.getChildren()) { + stack.push(psiElement); + } + } + } } - } - return false; + return false; } public static boolean isTestCaseClass(@NotNull PyClass cls) {