From 581367ff4c54f1223f6289d9e83fed0bac10bc60 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 10 Jun 2009 20:31:32 +0400 Subject: [PATCH] running all tests in folder rewritten in Jython compatible way; test added --- python/helpers/pycharm/utrunner.py | 10 ++++++---- python/testData/testRunner/tests/subfolder/subtest.py | 7 +++++++ .../jetbrains/python/testRunner/PyTestRunnerTest.java | 6 ++++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 python/testData/testRunner/tests/subfolder/subtest.py diff --git a/python/helpers/pycharm/utrunner.py b/python/helpers/pycharm/utrunner.py index d1e381927c99..bf42c8291b90 100644 --- a/python/helpers/pycharm/utrunner.py +++ b/python/helpers/pycharm/utrunner.py @@ -32,12 +32,14 @@ def loadSource(fileName): modules[moduleName] = module return module +def walkModules(modules, dirname, names): + for name in names: + if name.endswith(".py"): + modules.append(loadSource(os.path.join(dirname, name))) + def loadModulesFromFolderRec(folder): modules = [] - for root, dirs, files in os.walk(folder, topdown=False): - for name in files: - if name.endswith(".py"): - modules.append(loadSource(os.path.join(root, name))) + os.path.walk(folder, walkModules, modules) return modules testLoader = unittest.TestLoader() diff --git a/python/testData/testRunner/tests/subfolder/subtest.py b/python/testData/testRunner/tests/subfolder/subtest.py new file mode 100644 index 000000000000..b2c21b21d674 --- /dev/null +++ b/python/testData/testRunner/tests/subfolder/subtest.py @@ -0,0 +1,7 @@ +import unittest + +class SubTest(unittest.TestCase): + def test_in_subfolder(self): + self.assertEquals("foo", "fo" + "o") + + \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/testRunner/PyTestRunnerTest.java b/python/testSrc/com/jetbrains/python/testRunner/PyTestRunnerTest.java index 87f70b0b7a27..3befc64ec935 100644 --- a/python/testSrc/com/jetbrains/python/testRunner/PyTestRunnerTest.java +++ b/python/testSrc/com/jetbrains/python/testRunner/PyTestRunnerTest.java @@ -62,6 +62,12 @@ public class PyTestRunnerTest extends LightPlatformTestCase { assertEquals(3, result.length); } + public void testFolder() throws ExecutionException { + final File testDir = new File(PathManager.getHomePath(), "plugins/python/testData/testRunner/tests"); + String[] result = runUTRunner(testDir.getPath(), testDir.getPath() + "/"); + assertEquals(8, result.length); + } + private static String[] runUTRunner(String workDir, String... args) throws ExecutionException { File helpersDir = new File(PathManager.getHomePath(), "plugins/python/helpers"); File utRunner = new File(helpersDir, "pycharm/utrunner.py");