self.messages.testIgnored(self.getTestName(test), message=reason)
def _getSuite(self, test):
- if hasattr(test, "suite"):
+ try:
suite = strclass(test.suite)
suite_location = test.suite.location
location = test.suite.abs_location
location = location + ":" + str(test.lineno)
else:
location = location + ":" + str(test.test.lineno)
- else:
+ except AttributeError:
import inspect
try:
--- /dev/null
+# Checks Load test protocol for unittest
+import unittest
+
+
+class ParametricTestCase(unittest.TestCase):
+
+ def __init__(self, method="run_test", p=0):
+ super(ParametricTestCase, self).__init__(method)
+ self.p = p
+
+ def run_test(self):
+ self.assertGreater(self.p, 0)
+
+ def __str__(self):
+ return "ParametricTestCase(p={0.p})".format(self)
+
+ @staticmethod
+ def suite():
+
+ return unittest.TestSuite([
+
+ ParametricTestCase(p=1),
+ ParametricTestCase(p=2),
+ ParametricTestCase(p=3)
+
+ ])
+
+
+def load_tests(loader, tests, pattern):
+
+ suite = ParametricTestCase.suite()
+ tests.addTests(suite)
+
+ return tests
+
+
+if __name__ == "__main__":
+ unittest.main()
\ No newline at end of file
/**
* @author traff
*/
-public class PythonUnitTestingTest extends PyEnvTestCase {
+public final class PythonUnitTestingTest extends PyEnvTestCase {
public void testUTRunner() {
runPythonTest(new PyUnitTestProcessWithConsoleTestTask("/testRunner/env/unit", "test1.py") {
});
}
+ /**
+ * Checks <a href="https://docs.python.org/2/library/unittest.html#load-tests-protocol">Load test protocol</a>
+ */
+ public void testLoadProtocol() throws Exception {
+ runPythonTest(new PyUnitTestProcessWithConsoleTestTask("/testRunner/env/unit", "test_load_protocol.py") {
+ @Override
+ protected void checkTestResults(@NotNull final PyUnitTestProcessRunner runner,
+ @NotNull final String stdout,
+ @NotNull final String stderr,
+ @NotNull final String all) {
+ Assert.assertEquals("bad num of passed tests: unittest load protocol failed to find tests?", 3, runner.getPassedTestsCount());
+ runner.assertAllTestsPassed();
+ }
+ });
+ }
+
/**
* Ensures that skipped and erroneous tests do not lead to suite ignorance
*/