PY-25271: Do not provide pattern if checkbox disabled

This commit is contained in:
Ilya.Kazakevich
2017-07-24 18:17:23 +03:00
parent 5a63a6118d
commit 684449b5f0
3 changed files with 32 additions and 2 deletions
@@ -52,7 +52,7 @@ public class PythonDocTestCommandLineState extends PythonTestCommandLineStateBas
specs.add(myConfig.getScriptName() + "::" + myConfig.getClassName() + "::" + myConfig.getMethodName());
break;
case TEST_FOLDER:
if (!myConfig.getPattern().isEmpty())
if (myConfig.usePattern() && !myConfig.getPattern().isEmpty())
specs.add(myConfig.getFolderName() + "/" + ";" + myConfig.getPattern());
else
specs.add(myConfig.getFolderName() + "/");
@@ -4,12 +4,15 @@ import com.jetbrains.env.PyEnvTestCase;
import com.jetbrains.env.PyProcessWithConsoleTestTask;
import com.jetbrains.env.ut.PyDocTestProcessRunner;
import com.jetbrains.python.sdkTools.SdkCreationType;
import com.jetbrains.python.testing.AbstractPythonLegacyTestRunConfiguration;
import com.jetbrains.python.testing.doctest.PythonDocTestRunConfiguration;
import org.hamcrest.Matchers;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
/**
@@ -18,13 +21,40 @@ import static org.junit.Assert.assertEquals;
public final class PythonDocTestingTest extends PyEnvTestCase {
@Test
public void testConfigurationProducer() throws Exception {
runPythonTest(
new CreateConfigurationByFileTask<>(null, PythonDocTestRunConfiguration.class, "doctest_test.py"));
}
// ensure no pattern provided if checkbox disabled
@Test
public void testNoPatternIfDisabled() {
runPythonTest(new PyProcessWithConsoleTestTask<PyDocTestProcessRunner>("/testRunner/env/doc", SdkCreationType.EMPTY_SDK) {
@NotNull
@Override
protected PyDocTestProcessRunner createProcessRunner() throws Exception {
return new PyDocTestProcessRunner("subfolder", 0) {
@Override
protected void configurationCreatedAndWillLaunch(@NotNull PythonDocTestRunConfiguration configuration) throws IOException {
super.configurationCreatedAndWillLaunch(configuration);
configuration.setTestType(AbstractPythonLegacyTestRunConfiguration.TestType.TEST_FOLDER);
configuration.setPattern("ABC123");
configuration.usePattern(false);
}
};
}
@Override
protected void checkTestResults(@NotNull final PyDocTestProcessRunner runner,
@NotNull final String stdout,
@NotNull final String stderr,
@NotNull final String all) {
Assert.assertThat("Pattern used while it should not", all, Matchers.not(Matchers.containsString("ABC123")));
}
});
}
@Test
public void testUTRunner() {
runPythonTest(new PyProcessWithConsoleTestTask<PyDocTestProcessRunner>("/testRunner/env/doc", SdkCreationType.EMPTY_SDK) {