def test_should_return_list_with_single_module_when_directory_contains_package (self): when(os).walk("spam").thenReturn([("spam", ["eggs"], []), ("spam/eggs", [], ["__init__.py"])]) self.assertEquals(["eggs"], discover_modules("spam", ".py")) verify(os).walk("spam")
def execute_tests (test_source, suffix): output_log_file = StringIO() try: test_modules = discover_modules(test_source, suffix) tests = unittest.defaultTestLoader.loadTestsFromNames(test_modules) result = unittest.TextTestRunner(stream=output_log_file).run(tests) return (result, output_log_file.getvalue()) finally: output_log_file.close()
def execute_tool_on_modules (project, name, command_and_arguments, extend_pythonpath=True): source_dir = project.expand_path("$dir_source_main_python") modules = discover_modules(source_dir) command = as_list(command_and_arguments) + modules report_file = project.expand_path("$dir_reports/%s" % name) env = os.environ if extend_pythonpath: env["PYTHONPATH"] = source_dir return execute_command(command, report_file, env=env), report_file
def execute_tests(logger, test_source, suffix): test_module_names = discover_modules(test_source, suffix) test_modules = import_modules(test_module_names) test_collector = TestCollector() for test_module in test_modules: test_collector.collect_tests(test_module) test_runner = TestRunner() test_runner.add_test_run_listener(TestListener(logger)) return test_runner.run_tests(test_collector.test_suite)
def discover_modules_to_cover(project): return discover_modules(project.expand_path("$dir_source_main_python"))
def test_should_return_empty_list_when_directory_contains_single_file_not_matching_suffix (self): when(os).walk("spam").thenReturn([("spam", [], ["eggs.pi"])]) self.assertEquals([], discover_modules("spam", ".py")) verify(os).walk("spam")