get rid of http-client-3.1, avoid export XMLRPC, reduce usages of hamcrest

This commit is contained in:
Vladimir Krivosheev
2018-03-15 14:13:24 +01:00
parent 0776beb27c
commit ff096d46a2
10 changed files with 118 additions and 162 deletions

View File

@@ -142,7 +142,12 @@ public final class HttpRequests {
@NotNull
public static RequestBuilder request(@NotNull String url) {
return new RequestBuilderImpl(url);
return new RequestBuilderImpl(url, null);
}
@NotNull
public static RequestBuilder head(@NotNull String url) {
return new RequestBuilderImpl(url, "HEAD");
}
@NotNull
@@ -169,6 +174,7 @@ public final class HttpRequests {
private static class RequestBuilderImpl extends RequestBuilder {
private final String myUrl;
private final String myMethod;
private int myConnectTimeout = HttpConfigurable.CONNECTION_TIMEOUT;
private int myTimeout = HttpConfigurable.READ_TIMEOUT;
private int myRedirectLimit = HttpConfigurable.REDIRECT_LIMIT;
@@ -181,8 +187,9 @@ public final class HttpRequests {
private ConnectionTuner myTuner;
private UntrustedCertificateStrategy myUntrustedCertificateStrategy = null;
private RequestBuilderImpl(@NotNull String url) {
private RequestBuilderImpl(@NotNull String url, @Nullable String method) {
myUrl = url;
myMethod = method;
}
@Override
@@ -526,6 +533,10 @@ public final class HttpRequests {
connection.setUseCaches(false);
if (builder.myMethod != null) {
((HttpURLConnection)connection).setRequestMethod(builder.myMethod);
}
if (builder.myTuner != null) {
builder.myTuner.tune(connection);
}

View File

@@ -15,9 +15,8 @@
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="module" module-name="intellij.python.pydev" />
<orderEntry type="library" exported="" name="XmlRPC" level="project" />
<orderEntry type="library" name="XmlRPC" level="project" />
<orderEntry type="module" module-name="intellij.platform.debugger" />
<orderEntry type="library" name="http-client-3.1" level="project" />
<orderEntry type="module" module-name="intellij.regexp" exported="" />
<orderEntry type="module" module-name="intellij.platform.testRunner" />
<orderEntry type="module" module-name="intellij.platform.smRunner" />

View File

@@ -14,9 +14,8 @@
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="module" module-name="intellij.python.pydev" />
<orderEntry type="library" exported="" name="XmlRPC" level="project" />
<orderEntry type="library" name="XmlRPC" level="project" />
<orderEntry type="module" module-name="intellij.platform.debugger" />
<orderEntry type="library" name="http-client-3.1" level="project" />
<orderEntry type="module" module-name="intellij.regexp" exported="" />
<orderEntry type="module" module-name="intellij.platform.testRunner" />
<orderEntry type="module" module-name="intellij.platform.smRunner" />

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.documentation;
import com.intellij.ide.actions.ShowSettingsUtilImpl;
@@ -34,6 +20,7 @@ import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.QualifiedName;
import com.intellij.util.io.HttpRequests;
import com.jetbrains.python.PyNames;
import com.jetbrains.python.PyTokenTypes;
import com.jetbrains.python.PythonDialectsTokenSetProvider;
@@ -52,9 +39,6 @@ import com.jetbrains.python.pyi.PyiFile;
import com.jetbrains.python.pyi.PyiUtil;
import com.jetbrains.python.toolbox.ChainIterable;
import one.util.streamex.StreamEx;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jsoup.Jsoup;
@@ -496,17 +480,11 @@ public class PythonDocumentationProvider extends AbstractDocumentationProvider i
if (new File(url).exists()) {
return true;
}
final HttpClient client = new HttpClient();
final HttpConnectionManagerParams params = client.getHttpConnectionManager().getParams();
params.setSoTimeout(5 * 1000);
params.setConnectionTimeout(5 * 1000);
try {
final HeadMethod method = new HeadMethod(url);
final int rc = client.executeMethod(method);
if (rc == 404) {
return false;
}
HttpRequests.head(url).tryConnect();
}
catch (HttpRequests.HttpStatusException e) {
return false;
}
catch (IllegalArgumentException e) {
return false;

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.inspections
import com.intellij.codeInspection.LocalInspectionToolSession
@@ -115,7 +101,7 @@ class PyOverloadsInspection : PyInspection() {
if (name != null) {
result
.getOrPut(name, { SortedList<PyFunction> { f1, f2 -> f1.textOffset - f2.textOffset } })
.add(t!!)
.add(t)
}
return true

View File

@@ -1,3 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.env;
import com.google.common.collect.Lists;
@@ -16,7 +17,6 @@ import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.UIUtil;
import com.jetbrains.LoggingRule;
import com.jetbrains.TestEnv;
import org.hamcrest.Matchers;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.*;
@@ -30,6 +30,8 @@ import java.lang.reflect.Method;
import java.util.*;
import java.util.stream.Collectors;
import static com.intellij.testFramework.assertions.Assertions.assertThat;
/**
* @author traff
* <p>
@@ -136,11 +138,9 @@ public abstract class PyEnvTestCase {
@Before
public void setUp() {
if (myRequiredTags != null) { // Ensure all tags exist between available interpreters
Assume.assumeThat(
"Can't find some tags between all available interpreter, test (all methods) will be skipped",
getAvailableTags(),
Matchers.hasItems(myRequiredTags)
);
assertThat(getAvailableTags())
.describedAs("Can't find some tags between all available interpreter, test (all methods) will be skipped")
.contains(myRequiredTags);
}
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.env;
import com.google.common.collect.Sets;
@@ -25,7 +11,7 @@ import com.jetbrains.python.testing.tox.PyToxConfiguration;
import com.jetbrains.python.testing.tox.PyToxConfigurationFactory;
import com.jetbrains.python.testing.tox.PyToxTestTools;
import com.jetbrains.python.tools.sdkTools.SdkCreationType;
import org.hamcrest.Matchers;
import org.assertj.core.api.Condition;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
@@ -37,6 +23,8 @@ import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Ensure tox runner works
*
@@ -197,8 +185,10 @@ public final class PyToxTest extends PyEnvTestCase {
@NotNull final String stderr,
@NotNull final String all) {
final Set<String> environments = runner.getTestProxy().getChildren().stream().map(t -> t.getName()).collect(Collectors.toSet());
Assert.assertThat("Wrong environments launched", environments, Matchers.equalTo(Sets.newHashSet(envsToRun)));
Assert.assertThat("Argument not passed", all, Matchers.containsString("-v"));
assertThat(environments)
.describedAs("Wrong environments launched")
.containsExactly(envsToRun);
assertThat(all).contains("-v");
}
@NotNull
@@ -248,17 +238,19 @@ public final class PyToxTest extends PyEnvTestCase {
final Set<String> expectedInterpreters =
myInterpreters.entrySet().stream()
.filter(intAndExp -> intAndExp.getValue() != null)
.filter(o -> o.getValue().myUntilStep > runner.getCurrentRerunStep()) // Remove interp. which shouldn't be launched on this step
.map(intAndExp -> intAndExp.getKey())
.collect(Collectors.toSet());
.filter(intAndExp -> intAndExp.getValue() != null)
.filter(o -> o.getValue().myUntilStep >
runner.getCurrentRerunStep()) // Remove interp. which shouldn't be launched on this step
.map(intAndExp -> intAndExp.getKey())
.collect(Collectors.toSet());
// Interpreters are used in tox.ini, so there should be such text
for (final String interpreterName : expectedInterpreters) {
Assert.assertThat(String.format("No %s used from tox.ini", interpreterName), all, Matchers.containsString(interpreterName));
assertThat(all)
.describedAs(String.format("No %s used from tox.ini", interpreterName))
.contains(interpreterName);
}
if (!stderr.isEmpty()) {
Logger.getInstance(PyToxTest.class).warn(PyEnvTestCase.escapeTestMessage(stderr));
}
@@ -299,21 +291,21 @@ public final class PyToxTest extends PyEnvTestCase {
if (interpreterSuite.getChildren().size() == 1 && interpreterSuite.getChildren().get(0).getName().endsWith("SKIP")) {
// The only reason it may be skipped is it does not exist and skip_missing_interpreters = True
final String output = getTestOutput(interpreterSuite);
Assert.assertThat("Test marked skipped but not because interpreter not found", output,
Matchers.containsString("InterpreterNotFound"));
assertThat(output)
.describedAs("Test marked skipped but not because interpreter not found")
.contains("InterpreterNotFound");
}
// Interpretr run success,
//At least one interpreter tests should passed
final int numberOfTests = new SMRootTestsCounter(interpreterSuite.getRoot()).getPassedTestsCount();
Assert.assertThat(String.format("Not enough test passed, should %s at least", myMinimumSuccessTestCount),
numberOfTests,
Matchers.greaterThanOrEqualTo(myMinimumSuccessTestCount));
Assert.assertThat(String.format("Too many tests passed, should %s maximum", myMaximumSuccessTestCount),
numberOfTests,
Matchers.lessThanOrEqualTo(myMaximumSuccessTestCount));
assertThat(numberOfTests)
.describedAs(String.format("Not enough test passed, should %s at least", myMinimumSuccessTestCount))
.isGreaterThanOrEqualTo(myMinimumSuccessTestCount);
assertThat(numberOfTests)
.describedAs(String.format("Too many tests passed, should %s maximum", myMaximumSuccessTestCount))
.isLessThanOrEqualTo(myMaximumSuccessTestCount);
// Check expected output
final String message = String.format("Interpreter %s does not have expected string in output. \n ", interpreterName) +
String.format("All: %s \n", all) +
@@ -321,9 +313,9 @@ public final class PyToxTest extends PyEnvTestCase {
String.format("Error: %s \n", stderr);
Assert
.assertThat(message,
getTestOutput(interpreterSuite), Matchers.containsString(expectations.myExpectedOutput));
assertThat(message)
.describedAs(getTestOutput(interpreterSuite))
.contains(expectations.myExpectedOutput);
}
// Skipped interpreters should not be checked since we do not know which interpreters used on environemnt
@@ -333,10 +325,14 @@ public final class PyToxTest extends PyEnvTestCase {
expectedInterpreters.removeAll(skippedMissingInterpreters);
checkedInterpreters.removeAll(skippedMissingInterpreters);
Assert
.assertThat(String.format("No all interpreters from tox.ini used (test tree \n%s\n )", getTestTree(runner.getTestProxy(), 0)),
checkedInterpreters, Matchers.everyItem(Matchers.isIn(expectedInterpreters)));
assertThat(checkedInterpreters)
.describedAs(String.format("No all interpreters from tox.ini used (test tree \n%s\n )", getTestTree(runner.getTestProxy(), 0)))
.are(new Condition<String>() {
@Override
public boolean matches(String value) {
return expectedInterpreters.contains(value);
}
});
}
@NotNull

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.env.python.console;
import com.google.common.collect.Lists;
@@ -50,6 +36,8 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.Semaphore;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author traff
*/
@@ -375,8 +363,9 @@ public class PyConsoleTask extends PyExecutionFixtureTestTask {
protected void setValue(String varName, String value) throws PyDebuggerException, InterruptedException {
PyDebugValue val = getValue(varName);
Assert.assertTrue(String.format("Can't change variable's value: `%s` \n" +
"Output: %s", varName, output()), waitFor(myCommandSemaphore));
assertThat(waitFor(myCommandSemaphore))
.describedAs(String.format("Can't change variable's value: `%s` \n" + "Output: %s", varName, output()))
.isTrue();
myCommunication.changeVariable(val, value);
myCommandSemaphore.release();
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.env.python.testing;
import com.intellij.execution.ExecutionException;
@@ -48,10 +34,8 @@ import com.jetbrains.python.testing.PyUnitTestConfiguration;
import com.jetbrains.python.testing.PyUnitTestFactory;
import com.jetbrains.python.testing.PythonTestConfigurationsModel;
import com.jetbrains.python.tools.sdkTools.SdkCreationType;
import org.hamcrest.Matchers;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
@@ -59,8 +43,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static com.intellij.testFramework.assertions.Assertions.assertThat;
import static com.jetbrains.env.ut.PyScriptTestProcessRunner.TEST_TARGET_PREFIX;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;
/**
@@ -110,12 +94,15 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
});
final List<Throwable> throwables = getCapturesMessages().first;
Assert.assertThat("Exception shall be thrown", throwables, not(emptyCollectionOf(Throwable.class)));
assertThat(throwables)
.describedAs("Exception shall be thrown")
.isNotEmpty();
final Throwable exception = throwables.get(0);
Assert.assertThat("ExecutionException should be thrown", exception, instanceOf(ExecutionException.class));
Assert.assertThat("Wrong text", exception.getMessage(), equalTo(PyBundle.message("runcfg.tests.cant_rerun")));
Assert.assertThat("No messages displayed for exception", getCapturesMessages().second, not(emptyCollectionOf(String.class)));
assertThat(exception).isInstanceOf(ExecutionException.class);
assertThat(exception.getMessage()).isEqualTo(PyBundle.message("runcfg.tests.cant_rerun"));
assertThat(getCapturesMessages().second)
.describedAs("No messages displayed for exception")
.isNotEmpty();
stopMessageCapture();
}
@@ -144,7 +131,7 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
Arrays.stream(messages).forEach((s) -> console.print(s, ConsoleViewContentType.NORMAL_OUTPUT));
console.flushDeferredText();
Assert.assertEquals("TC messages filtered in wrong way", "Hello\nI am\nPyCharm", console.getText());
assertEquals("TC messages filtered in wrong way", "Hello\nI am\nPyCharm", console.getText());
});
}
});
@@ -165,7 +152,9 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@NotNull final String stdout,
@NotNull final String stderr,
@NotNull final String all) {
Assert.assertThat("Wrong runner used", all, containsString(PythonHelper.SETUPPY.asParamString()));
assertThat(all)
.describedAs("Wrong runner used")
.contains(PythonHelper.SETUPPY.asParamString());
}
});
}
@@ -225,8 +214,8 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@NotNull final String stdout,
@NotNull final String stderr,
@NotNull final String all) {
Assert.assertEquals("Runner did not stop after first fail", 1, runner.getAllTestsCount());
Assert.assertEquals("Bad tree produced for failfast", "Test tree:\n" +
assertEquals("Runner did not stop after first fail", 1, runner.getAllTestsCount());
assertEquals("Bad tree produced for failfast", "Test tree:\n" +
"[root]\n" +
".test_test\n" +
"..SomeTestCase\n" +
@@ -258,7 +247,9 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
".test_test\n" +
"..TestCase\n" +
"...test(~)\n", runner.getFormattedTestTree());
Assert.assertThat("non-ascii char broken in output", stdout, containsString("ошибка"));
assertThat(stdout)
.describedAs("non-ascii char broken in output")
.contains("ошибка");
}
});
}
@@ -314,7 +305,9 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@NotNull final String all) {
final MockPrinter printer = new MockPrinter();
runner.findTestByName("[test]").printOn(printer);
Assert.assertThat("Subtest assertEquals broken", printer.getStdErr(), Matchers.containsString("AssertionError: 'D' != 'a'"));
assertThat(printer.getStdErr())
.describedAs("Subtest assertEquals broken")
.contains("AssertionError: 'D' != 'a'");
}
});
}
@@ -330,7 +323,7 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@NotNull
@Override
protected PyUnitTestProcessRunner createProcessRunner() throws Exception {
protected PyUnitTestProcessRunner createProcessRunner() {
return new PyUnitTestProcessRunner(toFullPath(getMyScriptName()), 1);
}
@@ -408,7 +401,7 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@NotNull final String stdout,
@NotNull final String stderr,
@NotNull final String all) {
Assert.assertEquals("Output tree broken for skipped exception thrown in setup method", "Test tree:\n" +
assertEquals("Output tree broken for skipped exception thrown in setup method", "Test tree:\n" +
"[root]\n" +
".test_test\n" +
"..TestSimple\n" +
@@ -441,14 +434,14 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@NotNull final String stderr,
@NotNull final String all) {
if (runner.getCurrentRerunStep() == 0) {
Assert.assertEquals(runner.getFormattedTestTree(), 2, runner.getAllTestsCount());
Assert.assertEquals(runner.getFormattedTestTree(), 1, runner.getPassedTestsCount());
Assert.assertEquals(runner.getFormattedTestTree(), 1, runner.getFailedTestsCount());
assertEquals(runner.getFormattedTestTree(), 2, runner.getAllTestsCount());
assertEquals(runner.getFormattedTestTree(), 1, runner.getPassedTestsCount());
assertEquals(runner.getFormattedTestTree(), 1, runner.getFailedTestsCount());
}
else {
Assert.assertEquals(runner.getFormattedTestTree(), 1, runner.getAllTestsCount());
Assert.assertEquals(runner.getFormattedTestTree(), 0, runner.getPassedTestsCount());
Assert.assertEquals(runner.getFormattedTestTree(), 1, runner.getFailedTestsCount());
assertEquals(runner.getFormattedTestTree(), 1, runner.getAllTestsCount());
assertEquals(runner.getFormattedTestTree(), 0, runner.getPassedTestsCount());
assertEquals(runner.getFormattedTestTree(), 1, runner.getFailedTestsCount());
}
}
});
@@ -482,10 +475,10 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@NotNull final String stderr,
@NotNull final String all) {
if (runner.getCurrentRerunStep() == 0) {
Assert.assertEquals(stderr, 2, runner.getAllTestsCount());
assertEquals(stderr, 2, runner.getAllTestsCount());
}
else {
Assert.assertEquals(stderr, 1, runner.getAllTestsCount());
assertEquals(stderr, 1, runner.getAllTestsCount());
}
}
});
@@ -535,10 +528,10 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@NotNull String stderr,
@NotNull String all) {
if (runner.getCurrentRerunStep() == 0) {
Assert.assertEquals(runner.getFormattedTestTree(), 2, runner.getAllTestsCount());
assertEquals(runner.getFormattedTestTree(), 2, runner.getAllTestsCount());
}
else {
Assert.assertEquals(runner.getFormattedTestTree(), 1, runner.getAllTestsCount());
assertEquals(runner.getFormattedTestTree(), 1, runner.getAllTestsCount());
}
}
});
@@ -570,7 +563,7 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
"....(i=8)(-)\n" +
"....(i=9)(+)\n";
final String tree = runner.getFormattedTestTree();
Assert.assertEquals("Bad tree:" + tree, expectedResult, tree);
assertEquals("Bad tree:" + tree, expectedResult, tree);
}
});
}
@@ -585,8 +578,8 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@NotNull String stdout,
@NotNull String stderr,
@NotNull String all) {
Assert.assertEquals(runner.getFormattedTestTree(), 8, runner.getPassedTestsCount());
Assert.assertEquals(runner.getFormattedTestTree(), 2, runner.getIgnoredTestsCount());
assertEquals(runner.getFormattedTestTree(), 8, runner.getPassedTestsCount());
assertEquals(runner.getFormattedTestTree(), 2, runner.getIgnoredTestsCount());
}
});
}
@@ -618,12 +611,15 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
final PyFunction function = (PyFunction)elementToRightClickOn;
if (function.getName().equals("test_relative")) {
Assert.assertThat("Wrong dir for relative import", configuration.getWorkingDirectory(), endsWith("testRelativeImport"));
assertThat(configuration.getWorkingDirectory())
.describedAs("Wrong dir for relative import")
.endsWith("testRelativeImport");
assertEquals("Bad target", "src.tests.test_relative.ModuleTest.test_relative", configuration.getTarget().getTarget());
}
else if (function.getName().equals("test_no_relative")) {
Assert
.assertThat("Wrong dir for non relative import", configuration.getWorkingDirectory(), endsWith("testRelativeImport/src/tests"));
assertThat(configuration.getWorkingDirectory())
.describedAs("Wrong dir for non relative import")
.endsWith("testRelativeImport/src/tests");
assertEquals("Bad target", "test_no_relative.ModuleTest.test_no_relative", configuration.getTarget().getTarget());
}
else {
@@ -789,7 +785,7 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
protected void checkConfiguration(@NotNull final PyUnitTestConfiguration configuration,
@NotNull final PsiElement elementToRightClickOn) {
super.checkConfiguration(configuration, elementToRightClickOn);
Assert.assertEquals("UnitTest does not obey default working directory", SOME_RANDOM_DIR,
assertEquals("UnitTest does not obey default working directory", SOME_RANDOM_DIR,
configuration.getWorkingDirectorySafe());
}
}

View File

@@ -20,8 +20,10 @@
<orderEntry type="module" module-name="intellij.platform.smRunner" scope="TEST" />
<orderEntry type="library" scope="TEST" name="mockito" level="project" />
<orderEntry type="library" scope="TEST" name="Mocks" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest" level="project" />
<orderEntry type="module" module-name="intellij.platform.lang.tests" scope="TEST" />
<orderEntry type="module" module-name="intellij.python.tools" scope="TEST" />
<orderEntry type="library" name="XmlRPC" level="project" />
<orderEntry type="module" module-name="intellij.platform.testExtensions" scope="TEST" />
<orderEntry type="library" scope="TEST" name="hamcrest" level="project" />
</component>
</module>