diff --git a/python/helpers/pycharm/_jb_unittest_runner.py b/python/helpers/pycharm/_jb_unittest_runner.py index 39f92b935836..9ca46b4d00c8 100644 --- a/python/helpers/pycharm/_jb_unittest_runner.py +++ b/python/helpers/pycharm/_jb_unittest_runner.py @@ -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) diff --git a/python/testData/testRunner/env/unit/failFast/test_test.py b/python/testData/testRunner/env/unit/failFast/test_test.py new file mode 100644 index 000000000000..0143a75dad2e --- /dev/null +++ b/python/testData/testRunner/env/unit/failFast/test_test.py @@ -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 diff --git a/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java b/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java index 67cfc6e16a98..6eb357e57cd6 100644 --- a/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java +++ b/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java @@ -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. */