def run(self): # FIXME: Add Docstring # called from `pyvows.core:Vows.run()`, # which is called from `pyvows.cli.run()` start_time = time.time() result = VowsResult() if self.capture_output: self._capture_streams(self.capture_output) try: for suiteName, suitePlan in self.execution_plan.iteritems(): batches = [ batch for batch in self.suites[suiteName] if batch.__name__ in suitePlan['contexts'] ] for batch in batches: self.pool.spawn(self.run_context, result.contexts, batch.__name__, batch(None), suitePlan['contexts'][batch.__name__], index=-1, suite=suiteName) self.pool.join() finally: self._capture_streams(False) result.elapsed_time = elapsed(start_time) return result
def _run_setup_and_topic(ctx_obj, index): # If we're already mid-skip, don't run anything if skipReason: raise skipReason # Run setup function try: ctx_obj.setup() except Exception: raise VowsTopicError('setup', sys.exc_info()) # Find & run topic function if not hasattr(ctx_obj, 'topic'): # ctx_obj has no topic return ctx_obj._get_first_available_topic(index) try: topic_func = ctx_obj.topic topic_list = get_topics_for(topic_func, ctx_obj) start_time = time.time() if topic_func is None: return None topic = topic_func(*topic_list) ctx_result['topic_elapsed'] = elapsed(start_time) return topic except SkipTest: raise except Exception: raise VowsTopicError('topic', sys.exc_info())
def run(self): # FIXME: Add Docstring # called from `pyvows.core:Vows.run()`, # which is called from `pyvows.cli.run()` start_time = time.time() result = VowsResult() if self.capture_output: self._capture_streams(self.capture_output) try: for suiteName, suitePlan in self.execution_plan.iteritems(): batches = [batch for batch in self.suites[suiteName] if batch.__name__ in suitePlan['contexts']] for batch in batches: self.pool.spawn( self.run_context, result.contexts, batch.__name__, batch(None), suitePlan['contexts'][batch.__name__], index=-1, suite=suiteName ) self.pool.join() finally: self._capture_streams(False) result.elapsed_time = elapsed(start_time) return result
def run_vow(self, tests_collection, topic, ctx_obj, vow, vow_name, enumerated): # FIXME: Add Docstring start_time = time.time() vow_result = self.get_vow_result(vow, topic, ctx_obj, vow_name, enumerated) try: result = vow(ctx_obj, topic) vow_result['result'] = result vow_result['succeeded'] = True if self.on_vow_success: self.on_vow_success(vow_result) except SkipTest as se: vow_result['skip'] = se except: err_type, err_value, err_traceback = sys.exc_info() vow_result['error'] = { 'type': err_type, 'value': err_value, 'traceback': err_traceback } if self.on_vow_error: self.on_vow_error(vow_result) vow_result['elapsed'] = elapsed(start_time) tests_collection.append(vow_result) return vow_result
def run(self): # FIXME: Add Docstring # called from `pyvows.core:Vows.run()`, # which is called from `pyvows.cli.run()` start_time = time.time() result = VowsResult() for ctx_name, context in self.batches.iteritems(): self.run_context(result.contexts, ctx_name, context(None)) self.pool.join() result.elapsed_time = elapsed(start_time) return result
def run_vow_async(self, tests_collection, topic, ctx_instance, vow, vow_name, enumerated): # FIXME: Add Docstring start_time = time.time() filename, lineno = _get_file_info_for(vow._original) result_obj = { 'context_instance': ctx_instance, 'name': vow_name, 'enumerated': enumerated, 'result': None, 'topic': topic, 'error': None, 'succeeded': False, 'file': filename, 'lineno': lineno, 'elapsed': 0 } try: result = vow(ctx_instance, topic) result_obj['result'] = result result_obj['succeeded'] = True if self.on_vow_success: self.on_vow_success(result_obj) except: # FIXME: # # Either... # * Describe why we're catching every exception, or # * Fix to catch specific kinds of exceptions err_type, err_value, err_traceback = sys.exc_info() result_obj['error'] = { 'type': err_type, 'value': err_value, 'traceback': err_traceback } if self.on_vow_error: self.on_vow_error(result_obj) result_obj['elapsed'] = elapsed(start_time) tests_collection.append(result_obj) return result_obj
def _init_topic(): topic = None if hasattr(ctx_instance, 'topic'): start_time = time.time() try: topic_func = getattr(ctx_instance, 'topic') topic_list = _get_topics_for(topic_func, ctx_instance) topic = topic_func(*topic_list) except Exception as e: topic = e topic.error = ctx_instance.topic_error = sys.exc_info() context_obj['topic_elapsed'] = elapsed(start_time) else: # ctx_instance has no topic topic = ctx_instance._get_first_available_topic(index) return topic
def run_vow(self, tests_collection, topic, ctx_obj, vow, vow_name, enumerated): # FIXME: Add Docstring start_time = time.time() filename, lineno = get_file_info_for(vow._original) vow_result = { 'context_instance': ctx_obj, 'name': vow_name, 'enumerated': enumerated, 'result': None, 'topic': topic, 'error': None, 'succeeded': False, 'file': filename, 'lineno': lineno, 'elapsed': 0 } try: result = vow(ctx_obj, topic) vow_result['result'] = result vow_result['succeeded'] = True if self.on_vow_success: self.on_vow_success(vow_result) except: # FIXME: # # Either... # * Describe why we're catching every exception, or # * Fix to catch specific kinds of exceptions err_type, err_value, err_traceback = sys.exc_info() vow_result['error'] = { 'type': err_type, 'value': err_value, 'traceback': err_traceback } if self.on_vow_error: self.on_vow_error(vow_result) vow_result['elapsed'] = elapsed(start_time) tests_collection.append(vow_result) return vow_result
def run(self): # FIXME: Add Docstring # called from `pyvows.core:Vows.run()`, # which is called from `pyvows.cli.run()` start_time = time.time() result = VowsResult() for suite, batches in self.suites.items(): for batch in batches: self.pool.spawn(self.run_context, result.contexts, ctx_name=batch.__name__, ctx_obj=batch(None), index=-1, suite=suite) self.pool.join() result.elapsed_time = elapsed(start_time) return result
def _run_setup_and_topic(ctx_obj): try: ctx_obj.setup() except Exception as e: topic = e topic.error = ctx_obj.topic_error = ('setup', sys.exc_info()) else: # setup() had no errors topic = None if not hasattr(ctx_obj, 'topic'): # ctx_obj has no topic topic = ctx_obj._get_first_available_topic(index) else: start_time = time.time() try: topic_func = getattr(ctx_obj, 'topic') topic_list = get_topics_for(topic_func, ctx_obj) topic = topic_func(*topic_list) except Exception as e: topic = e topic.error = ctx_obj.topic_error = sys.exc_info() ctx_result['topic_elapsed'] = elapsed(start_time) finally: return topic
def _run_setup_and_topic(ctx_obj, index): # Run setup function try: ctx_obj.setup() except Exception as e: raise VowsTopicError('setup', sys.exc_info()) # Find & run topic function if not hasattr(ctx_obj, 'topic'): # ctx_obj has no topic return ctx_obj._get_first_available_topic(index) try: topic_func = ctx_obj.topic topic_list = get_topics_for(topic_func, ctx_obj) start_time = time.time() topic = topic_func(*topic_list) ctx_result['topic_elapsed'] = elapsed(start_time) return topic except Exception as e: raise VowsTopicError('topic', sys.exc_info())
def run(self): # FIXME: Add Docstring # called from `pyvows.core:Vows.run()`, # which is called from `pyvows.cli.run()` start_time = time.time() result = VowsResult() for suite, batches in self.suites.items(): for batch in batches: self.pool.spawn( self.run_context, result.contexts, ctx_name = batch.__name__, ctx_obj = batch(None), index = -1, suite = suite ) self.pool.join() result.elapsed_time = elapsed(start_time) return result
try: result = vow(ctx_obj, topic) vow_result['result'] = result vow_result['succeeded'] = True if self.on_vow_success: self.on_vow_success(vow_result) except SkipTest, se: vow_result['skip'] = se except: err_type, err_value, err_traceback = sys.exc_info() vow_result['error'] = { 'type': err_type, 'value': err_value, 'traceback': err_traceback } if self.on_vow_error: self.on_vow_error(vow_result) vow_result['elapsed'] = elapsed(start_time) tests_collection.append(vow_result) return vow_result class VowsTopicError(Exception): """Wraps an error in the setup or topic functions.""" def __init__(self, source, exc_info): self.source = source self.exc_info = exc_info
if self.on_vow_pending: self.on_vow_pending(vow_result) else: vow_result['succeeded'] = True if self.on_vow_success: self.on_vow_success(vow_result) except SkipTest, se: vow_result['skip'] = se except: err_type, err_value, err_traceback = sys.exc_info() vow_result['error'] = { 'type': err_type, 'value': err_value, 'traceback': err_traceback } if self.on_vow_error: self.on_vow_error(vow_result) vow_result['elapsed'] = elapsed(start_time) tests_collection.append(vow_result) return vow_result class VowsTopicError(Exception): """Wraps an error in the setup or topic functions.""" def __init__(self, source, exc_info): self.source = source self.exc_info = exc_info