mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-23673: "blockClosed" can be called on setup finish, not only on subtest.
This commit is contained in:
@@ -205,12 +205,21 @@ class NewTeamcityServiceMessages(_old_service_messages):
|
||||
return test_name
|
||||
|
||||
# Blocks are used for 2 cases now:
|
||||
# 1) Unittest subtests
|
||||
# 1) Unittest subtests (only closed, opened by subTestBlockOpened)
|
||||
# 2) setup/teardown (does not work, see https://github.com/JetBrains/teamcity-messages/issues/114)
|
||||
# def blockOpened(self, name, flowId=None):
|
||||
# self.testStarted(".".join(TREE_MANAGER.current_branch + [self._fix_setup_teardown_name(name)]))
|
||||
|
||||
def blockClosed(self, name, flowId=None):
|
||||
|
||||
# If _latest_subtest_result is not set or does not exist we closing setup method, not a subtest
|
||||
try:
|
||||
if not self._latest_subtest_result:
|
||||
return
|
||||
except AttributeError:
|
||||
return
|
||||
|
||||
# If we here that means we are closing subtest
|
||||
test_name = ".".join(TREE_MANAGER.current_branch)
|
||||
if self._latest_subtest_result == "Failure":
|
||||
self.testFailed(test_name)
|
||||
@@ -220,8 +229,6 @@ class NewTeamcityServiceMessages(_old_service_messages):
|
||||
self.testFinished(test_name)
|
||||
self._latest_subtest_result = None
|
||||
|
||||
|
||||
|
||||
def subTestBlockOpened(self, name, subTestResult, flowId=None):
|
||||
self.testStarted(".".join(TREE_MANAGER.current_branch + [name]))
|
||||
self._latest_subtest_result = subTestResult
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
class FooTest(TestCase):
|
||||
def setUp(self):
|
||||
print(1)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
print(1)
|
||||
|
||||
def test_test(self):
|
||||
print(3)
|
||||
|
||||
def test_2_test(self):
|
||||
self.fail("D")
|
||||
|
||||
def tearDown(self):
|
||||
print("A")
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
print("A")
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,18 @@ import static org.junit.Assert.assertEquals;
|
||||
@EnvTestTagsRequired(tags = "nose")
|
||||
public final class PythonNoseTestingTest extends PyEnvTestCase {
|
||||
|
||||
// Ensures setup/teardown does not break anything
|
||||
@Test
|
||||
public void testSetupTearDown() throws Exception {
|
||||
runPythonTest(new SetupTearDownTestTask<PyNoseTestProcessRunner>(){
|
||||
@NotNull
|
||||
@Override
|
||||
protected PyNoseTestProcessRunner createProcessRunner() throws Exception {
|
||||
return new PyNoseTestProcessRunner("test_test.py", 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Ensure slow test is not run when --attr="!slow" is provided
|
||||
@Test
|
||||
|
||||
@@ -37,6 +37,19 @@ import static org.junit.Assert.assertEquals;
|
||||
@EnvTestTagsRequired(tags = "pytest")
|
||||
public final class PythonPyTestingTest extends PyEnvTestCase {
|
||||
|
||||
|
||||
// Ensures setup/teardown does not break anything
|
||||
@Test
|
||||
public void testSetupTearDown() throws Exception {
|
||||
runPythonTest(new SetupTearDownTestTask<PyTestTestProcessRunner>(){
|
||||
@NotNull
|
||||
@Override
|
||||
protected PyTestTestProcessRunner createProcessRunner() throws Exception {
|
||||
return new PyTestTestProcessRunner("test_test.py", 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Ensure slow test is not run when -m "not slow" is provided
|
||||
@Test
|
||||
public void testMarkerWithSpaces() throws Exception {
|
||||
|
||||
@@ -48,6 +48,18 @@ import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
public final class PythonUnitTestingTest extends PyEnvTestCase {
|
||||
|
||||
// Ensures setup/teardown does not break anything
|
||||
@Test
|
||||
public void testSetupTearDown() throws Exception {
|
||||
runPythonTest(new SetupTearDownTestTask<PyUnitTestProcessRunner>(){
|
||||
@NotNull
|
||||
@Override
|
||||
protected PyUnitTestProcessRunner createProcessRunner() throws Exception {
|
||||
return new PyUnitTestProcessRunner("test_test.py", 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EnvTestTagsRequired(tags = "python3") // No subtest in py2
|
||||
@Test
|
||||
public void testSubtest() throws Exception {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.jetbrains.env.python.testing;
|
||||
|
||||
import com.jetbrains.env.PyProcessWithConsoleTestTask;
|
||||
import com.jetbrains.env.ut.PyScriptTestProcessRunner;
|
||||
import com.jetbrains.python.sdkTools.SdkCreationType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* Runs test with setup/teardown (script shall be test_test.py) and checks it works
|
||||
*
|
||||
* @author Ilya.Kazakevich
|
||||
*/
|
||||
abstract class SetupTearDownTestTask<T extends PyScriptTestProcessRunner<?>> extends PyProcessWithConsoleTestTask<T> {
|
||||
|
||||
SetupTearDownTestTask() {
|
||||
super("testRunner/env/setup_teardown/", SdkCreationType.SDK_PACKAGES_ONLY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void checkTestResults(@NotNull final T runner,
|
||||
@NotNull final String stdout,
|
||||
@NotNull final String stderr,
|
||||
@NotNull final String all) {
|
||||
|
||||
if (runner.getCurrentRerunStep() == 0) {
|
||||
Assert.assertEquals(runner.getFormattedTestTree(), 1, runner.getFailedTestsCount());
|
||||
Assert.assertEquals(runner.getFormattedTestTree(), 1, runner.getPassedTestsCount());
|
||||
Assert.assertEquals(runner.getFormattedTestTree(), 2, runner.getAllTestsCount());
|
||||
}
|
||||
else {
|
||||
Assert.assertEquals(runner.getFormattedTestTree(), 1, runner.getFailedTestsCount());
|
||||
Assert.assertEquals(runner.getFormattedTestTree(), 0, runner.getPassedTestsCount());
|
||||
Assert.assertEquals(runner.getFormattedTestTree(), 1, runner.getAllTestsCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user