mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-14221: Do not instantiate unittest runner explicitly
See Leonid's comments on https://github.com/JetBrains/teamcity-messages/issues/135
This commit is contained in:
@@ -30,8 +30,6 @@ if __name__ == '__main__':
|
||||
additional_args += targets
|
||||
args += additional_args
|
||||
jb_doc_args("unittests", args)
|
||||
test_runner = unittestpy.TeamcityTestRunner()
|
||||
test_runner.buffer = True
|
||||
# Working dir should be on path, that is how unittest work when launched from command line
|
||||
sys.path.append(os.getcwd())
|
||||
main(argv=args, module=None, testRunner=test_runner)
|
||||
main(argv=args, module=None, testRunner=unittestpy.TeamcityTestRunner, buffer=True)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
from unittest import TestCase
|
||||
|
||||
class SomeTestCase(TestCase):
|
||||
def test_1_test(self):
|
||||
assert False
|
||||
|
||||
def test_2_test(self):
|
||||
pass
|
||||
|
||||
def test_3_test(self):
|
||||
assert False
|
||||
@@ -52,6 +52,46 @@ import static org.junit.Assert.assertEquals;
|
||||
public final class PythonUnitTestingTest extends PyEnvTestCase {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* tests failfast as example of argument
|
||||
*/
|
||||
@Test
|
||||
public void testFailFast() throws Exception {
|
||||
|
||||
runPythonTest(new PyUnitTestProcessWithConsoleTestTask("testRunner/env/unit/failFast", "test_test.py") {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected PyUnitTestProcessRunner createProcessRunner() throws Exception {
|
||||
return new PyUnitTestProcessRunner(toFullPath(myScriptName), 1){
|
||||
@Override
|
||||
protected void configurationCreatedAndWillLaunch(@NotNull final PyUniversalUnitTestConfiguration configuration) throws IOException {
|
||||
super.configurationCreatedAndWillLaunch(configuration);
|
||||
configuration.setAdditionalArguments("-f"); //FailFast
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkTestResults(@NotNull final PyUnitTestProcessRunner runner,
|
||||
@NotNull final String stdout,
|
||||
@NotNull final String stderr,
|
||||
@NotNull final String all) {
|
||||
Assert.assertEquals("Runner did not stop after first fail", 1, runner.getAllTestsCount());
|
||||
runner.getFormattedTestTree();
|
||||
Assert.assertEquals("Bad tree produced for failfast", "Test tree:\n" +
|
||||
"[root]\n" +
|
||||
".test_test\n" +
|
||||
"..SomeTestCase\n" +
|
||||
"...test_1_test(-)\n", runner.getFormattedTestTree());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* tests with docstrings are reported as "test.name (text)" by unittest.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user