mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-35394: Don't break when setupClass reported several times.
With xdist, setupClass may be reported several times (one for each test). Next report leads to error since it is already reported as closed. We ignore setup methods: there is no sane place to display them in the test tree, anyway. GitOrigin-RevId: 3c7bcf2f3942e78fcbfba5fb0cae1cbdb2c92730
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0247094adb
commit
6eceabff48
@@ -64,6 +64,9 @@ class ParallelTreeManager(object):
|
||||
def get_node_ids(self, test_name):
|
||||
"""
|
||||
|
||||
:return: (current_node_id, parent_node_id)
|
||||
:return: (current_node_id, parent_node_id) or None, None if message must be ignored
|
||||
"""
|
||||
return self._branches[tuple(test_name.split("."))]
|
||||
try:
|
||||
return self._branches[tuple(test_name.split("."))]
|
||||
except KeyError:
|
||||
return None, None
|
||||
|
||||
@@ -101,6 +101,8 @@ class NewTeamcityServiceMessages(_old_service_messages):
|
||||
return
|
||||
|
||||
current, parent = _TREE_MANAGER_HOLDER.manager.get_node_ids(properties["name"])
|
||||
if not current and not parent:
|
||||
return
|
||||
# Shortcut for name
|
||||
try:
|
||||
properties["name"] = str(properties["name"]).split(".")[-1]
|
||||
@@ -189,6 +191,8 @@ class NewTeamcityServiceMessages(_old_service_messages):
|
||||
def _write_finished_message():
|
||||
# testName, captureStandardOutput, flowId
|
||||
current, parent = _TREE_MANAGER_HOLDER.manager.get_node_ids(testName)
|
||||
if not current and not parent:
|
||||
return
|
||||
args = {"nodeId": current, "parentNodeId": parent, "name": testName}
|
||||
|
||||
# TODO: Doc copy/paste with parent, extract
|
||||
|
||||
@@ -98,8 +98,8 @@ envs {
|
||||
|
||||
createPython("py35_django22_full",
|
||||
"3.5.4",
|
||||
["ipython==2.1", "django==2.2", "behave", "jinja2", "tox>=2.0", "nose", "pytest", "django-nose", "behave-django"],
|
||||
"python3.4\npython3\nipython\nipython200\nskeletons\ndjango\nbehave\ntox\njinja2\npython34\npackaging\npytest\nnose\ndjango-nose\nbehave-django\ndjango2",
|
||||
["ipython==2.1", "django==2.2", "behave", "jinja2", "tox>=2.0", "nose", "pytest", "django-nose", "behave-django", "pytest-xdist"],
|
||||
"python3.4\npython3\nipython\nipython200\nskeletons\ndjango\nbehave\ntox\njinja2\npython34\npackaging\npytest\nnose\ndjango-nose\nbehave-django\ndjango2\nxdist",
|
||||
true)
|
||||
|
||||
createPython("py36_django2_1",
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class ExampleTestCase(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
print('2')
|
||||
|
||||
def test_example(self):
|
||||
assert 1 == 1
|
||||
@@ -286,6 +286,39 @@ public final class PythonPyTestingTest extends PyEnvTestCase {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@EnvTestTagsRequired(tags = "xdist")
|
||||
public void testParallelWithSetup() {
|
||||
runPythonTest(
|
||||
new PyProcessWithConsoleTestTask<PyTestTestProcessRunner>("/testRunner/env/pytest/parallel", SdkCreationType.EMPTY_SDK) {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected PyTestTestProcessRunner createProcessRunner() {
|
||||
return new PyTestTestProcessRunner("test_parallel.py", 0) {
|
||||
@Override
|
||||
protected void configurationCreatedAndWillLaunch(@NotNull PyTestConfiguration configuration) throws IOException {
|
||||
super.configurationCreatedAndWillLaunch(configuration);
|
||||
configuration.setAdditionalArguments("-n 4");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkTestResults(@NotNull PyTestTestProcessRunner runner,
|
||||
@NotNull String stdout,
|
||||
@NotNull String stderr,
|
||||
@NotNull String all, int exitCode) {
|
||||
Assert.assertThat("xdist not launched?", all, Matchers.containsString("xdist"));
|
||||
Assert.assertEquals("Test tree:\n" +
|
||||
"[root](+)\n" +
|
||||
".test_parallel(+)\n" +
|
||||
"..ExampleTestCase(+)\n" +
|
||||
"...test_example(+)\n", runner.getFormattedTestTree());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Ensure test survives patched strftime
|
||||
@Test
|
||||
public void testMonkeyPatch() {
|
||||
|
||||
Reference in New Issue
Block a user