PY-18839: Adding test

This commit is contained in:
Ilya.Kazakevich
2016-07-19 17:35:10 +03:00
parent d9ed9d471b
commit 5045164a0d
3 changed files with 35 additions and 2 deletions
+13
View File
@@ -0,0 +1,13 @@
import unittest
from unittest import TestCase
class BaseTestCases:
class TestAbstract(TestCase):
def test_a(self):
raise Exception()
class TestDerived(BaseTestCases.TestAbstract):
def test_b(self):
print("Running from derived class")
@@ -15,7 +15,6 @@
*/
package com.jetbrains.env.python.testing;
import com.jetbrains.env.PyEnvTestCase;
import com.jetbrains.env.PyProcessWithConsoleTestTask;
import com.jetbrains.env.ut.PyUnitTestProcessRunner;
import com.jetbrains.python.sdkTools.SdkCreationType;
@@ -29,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
*/
abstract class PyUnitTestProcessWithConsoleTestTask extends PyProcessWithConsoleTestTask<PyUnitTestProcessRunner> {
@NotNull
private final String myScriptName;
protected final String myScriptName;
PyUnitTestProcessWithConsoleTestTask(@NotNull final String relativePathToTestData, @NotNull final String scriptName) {
super(relativePathToTestData, SdkCreationType.EMPTY_SDK);
@@ -89,6 +89,27 @@ public final class PythonUnitTestingTest extends PyEnvTestCase {
});
}
/**
* Ensure rerun test works even if test is declared in parent
*/
@Test
public void testRerunDerivedClass() throws Exception {
runPythonTest(new PyUnitTestProcessWithConsoleTestTask("/testRunner/env/unit", "rerun_derived.py") {
@Override
protected void checkTestResults(@NotNull final PyUnitTestProcessRunner runner,
@NotNull final String stdout,
@NotNull final String stderr,
@NotNull final String all) {
Assert.assertThat("Premature error", stderr, isEmptyString());
Assert.assertThat("Wrong number of failed tests", runner.getFailedTestsCount(), equalTo(1));
}
@NotNull
@Override
protected PyUnitTestProcessRunner createProcessRunner() throws Exception {
return new PyUnitTestProcessRunner(myScriptName, 2);
}
});
}
/**
* Run tests, delete file and click "rerun" should throw exception and display error since test ids do not point to correct PSI