Author: bugman Date: Sun Jun 16 17:23:11 2013 New Revision: 20152 URL: http://svn.gna.org/viewcvs/relax?rev=20152&view=rev Log: Fixes and improvements to Gary Thompson's unit_test_runner.py script. The printouts have been improved and the script can now handle more than 3 levels of directories for a package. Modified: trunk/test_suite/unit_tests/unit_test_runner.py Modified: trunk/test_suite/unit_tests/unit_test_runner.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/unit_test_runner.py?rev=20152&r1=20151&r2=20152&view=diff ============================================================================== --- trunk/test_suite/unit_tests/unit_test_runner.py (original) +++ trunk/test_suite/unit_tests/unit_test_runner.py Sun Jun 16 17:23:11 2013 @@ -593,15 +593,16 @@ # Title printout. if self.verbose: - print('testing units...') + print('\ntesting units...') print('----------------') print('') module_paths = self.paths_from_test_module(self.test_module) if self.verbose: - print('root path: ', self.root_path) - print('system directory: ', self.system_directory) - print('unit test directory:', self.unit_test_directory) + print('test module: %s' % self.test_module) + print('root path: %s' % self.root_path) + print('system directory: %s' % self.system_directory) + print('unit test directory: %s' % self.unit_test_directory) print('') for i, elem in enumerate(module_paths): print('module path %d: %s' % (i, elem)) @@ -626,19 +627,20 @@ # Execute specific tests. if tests == None: - for module_path in module_paths: - print(module_path) - path_len = len(module_path) - if path_len <= 1: - continue - elif path_len == 2: - print('trying to load 2: ', module_path[0], module_path[1]) - tests = load_test_case('', module_path[0], module_path[1]) - else: - print('trying to load 3: ', os.path.join(*module_path[:-2]), module_path[-2], module_path[-1]) - tests = load_test_case(os.path.join(*module_path[:-2]), module_path[-2], module_path[-1]) - if tests != None: - break + for module_tuple in module_paths: + # The package path. + package_path = module_tuple[0] + for i in range(len(module_tuple)-2): + package_path = os.path.join(package_path, module_tuple[i]) + + # The module name. + module_name = module_tuple[-2] + + # The class name. + class_name = module_tuple[-1] + + # Load the tests. + tests = load_test_case(package_path, module_name, class_name) if runner == None: runner = unittest.TextTestRunner()