コード例 #1
0
ファイル: gevent.py プロジェクト: usteiner9/pyvows
    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
コード例 #2
0
ファイル: gevent.py プロジェクト: coreypobrien/pyvows
    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
コード例 #3
0
    def run(self):
        start_time = time.time()
        result = VowsResult()

        for name, context in self.vows.iteritems():
            self.run_context(result.contexts, name, context(None))

        self.pool.join()

        end_time = time.time()
        result.ellapsed_time = float(end_time - start_time)
        return result
コード例 #4
0
ファイル: runner.py プロジェクト: dhm116/pyvows
    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
コード例 #5
0
ファイル: runner.py プロジェクト: BigData-Tools/pyvows
    def run(self):
        start_time = time.time()
        result = VowsResult()

        for name, context in self.vows.iteritems():
            self.run_context(result.contexts, name, context, None)

        self.pool.waitall()

        while self.async_topics:
            time.sleep(0.01)

        self.pool.waitall()

        end_time = time.time()
        result.ellapsed_time = float(end_time - start_time)
        return result
コード例 #6
0
    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
コード例 #7
0
ファイル: patch.py プロジェクト: albertoniderhofer/testRepo1
 def run(cls, on_vow_success, on_vow_error, capture_error=False):
     # Run batches in series
     r = VowsResult()
     for suite, batches in Vows.suites.items():
         for batch in batches:
             suites = {suite: [batch]}
             plan = ExecutionPlanner(suites, set(Vows.exclusion_patterns),
                                     set(Vows.inclusion_patterns)).plan()
             result = VowsRunner(suites, Vows.Context, on_vow_success,
                                 on_vow_error, plan, capture_error).run()
             r.contexts += result.contexts
             r.elapsed_time += result.elapsed_time
     return r
コード例 #8
0
ファイル: gevent.py プロジェクト: Zearin/pyvows
    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
コード例 #9
0
ファイル: patch.py プロジェクト: yash-dholakia/python-jwt
 def run(cls, on_vow_success, on_vow_error):
     # Run batches in series
     r = VowsResult()
     for suite, batches in Vows.suites.items():
         for batch in batches:
             result = VowsRunner({suite: [batch]},
                                 Vows.Context,
                                 on_vow_success,
                                 on_vow_error,
                                 Vows.exclusion_patterns).run()
             r.contexts += result.contexts
             r.elapsed_time += result.elapsed_time
     return r
コード例 #10
0
    def print_context(self, name, context, file=sys.stdout):
        #   FIXME: Add Docstring
        #
        #       *   Is this only used in certain cases?
        #           *   If so, which?
        self.indent += 1

        if (self.verbosity >= V_VERBOSE
                or not self.result.eval_context(context)):
            contextName = StringIO()
            self.humanized_print(name, file=contextName)
            contextName = contextName.getvalue().replace('\n', '')
            if context.get('skip', None):
                contextName += ' (SKIPPED: {0})'.format(str(context['skip']))
            print(contextName, file=file)

        def _print_successful_test():
            honored = ensure_encoded(VowsReporter.HONORED)
            topic = ensure_encoded(test['topic'])
            name = ensure_encoded(test['name'])

            if self.verbosity == V_VERBOSE:
                self.humanized_print('{0} {1}'.format(honored, name),
                                     file=file)
            elif self.verbosity >= V_EXTRA_VERBOSE:
                if test['enumerated']:
                    self.humanized_print('{0} {1} - {2}'.format(
                        honored, topic, name),
                                         file=file)
                else:
                    self.humanized_print('{0} {1}'.format(honored, name),
                                         file=file)

        def _print_skipped_test():
            if self.verbosity >= V_VERBOSE:
                message = StringIO()
                self.humanized_print('{0} {1}'.format(VowsReporter.SKIPPED,
                                                      test['name']),
                                     file=message)
                message = message.getvalue().replace('\n', '')
                if test['skip'] != context['skip']:
                    message = '{0} (SKIPPED: {1})'.format(
                        message, str(test['skip']))
                print(message, file=file)

        def _print_failed_test():
            ctx = test['context_instance']

            def _print_traceback():
                self.indent += 2

                ### NOTE:
                ###     Commented out try/except; potential debugging hinderance

                #try:

                traceback_args = (test['error']['type'],
                                  test['error']['value'],
                                  test['error']['traceback'])
                self.print_traceback(*traceback_args, file=file)

                # except Exception:
                #     # should never occur!
                #     err_msg = '''Unexpected error in PyVows!
                #                  PyVows error occurred in: ({0!s})
                #                  Context was: {1!r}
                #
                #               '''
                #     # from os.path import abspath
                #     raise VowsInternalError(err_msg, 'pyvows.reporting.test', ctx)

                # print file and line number
                if 'file' in test:
                    file_msg = 'found in {test[file]} at line {test[lineno]}'.format(
                        test=test)
                    print('\n',
                          self.indent_msg(red(file_msg)),
                          '\n',
                          file=file)

                self.indent -= 2

            self.humanized_print('{0} {test}'.format(VowsReporter.BROKEN,
                                                     test=test['name']),
                                 file=file)

            # print generated topic (if applicable)
            if ctx.generated_topic:
                value = yellow(test['topic'])
                self.humanized_print('', file=file)
                self.humanized_print('\tTopic value:', file=file)
                self.humanized_print('\t{value}'.format(value=value),
                                     file=file)
                self.humanized_print('\n' * 2, file=file)

            # print traceback
            _print_traceback()

        # Show any error raised by the setup, topic or teardown functions
        if context.get('error', None):
            e = context['error']
            print('\n',
                  self.indent_msg(blue("Error in {0!s}:".format(e.source))),
                  file=file)
            self.print_traceback(*e.exc_info, file=file)

        else:
            for test in context['tests']:
                if VowsResult.test_is_successful(test):
                    _print_successful_test()
                elif test['skip']:
                    _print_skipped_test()
                else:
                    _print_failed_test()

        # I hereby (re)curse you...!
        for context in context['contexts']:
            self.print_context(context['name'], context, file=file)

        self.indent -= 1
コード例 #11
0
 def topic(self):
     v = VowsTestReporter(VowsResult(), 0)
     return v
コード例 #12
0
ファイル: test.py プロジェクト: lamogura/pyvows
    def print_context(self, name, context, file=sys.stdout):
        #   FIXME: Add Docstring
        #
        #       *   Is this only used in certain cases?
        #           *   If so, which?
        self.indent += 1

        if (self.verbosity >= V_VERBOSE or not self.result.eval_context(context)):
            contextName = StringIO()
            self.humanized_print(name, file=contextName)
            contextName = contextName.getvalue().replace('\n', '')
            if context.get('skip', None):
                contextName += ' (SKIPPED: {0})'.format(str(context['skip']))
            print(contextName, file=file)

        def _print_successful_test():
            honored = ensure_encoded(VowsReporter.HONORED)
            topic = ensure_encoded(test['topic'])
            name = ensure_encoded(test['name'])

            if self.verbosity == V_VERBOSE:
                self.humanized_print('{0} {1}'.format(honored, name), file=file)
            elif self.verbosity >= V_EXTRA_VERBOSE:
                if test['enumerated']:
                    self.humanized_print('{0} {1} - {2}'.format(honored, topic, name), file=file)
                else:
                    self.humanized_print('{0} {1}'.format(honored, name), file=file)

        def _print_pending_test():
            pending = ensure_encoded(VowsReporter.PENDING)
            topic = ensure_encoded(test['topic'])
            name = ensure_encoded(test['name'])

            if self.verbosity == V_VERBOSE:
                self.humanized_print('{0} {1}'.format(pending, name), file=file, color=cyan)
            elif self.verbosity >= V_EXTRA_VERBOSE:
                if test['enumerated']:
                    self.humanized_print('{0} {1} - {2}'.format(pending, topic, name), file=file, color=cyan)
                else:
                    self.humanized_print('{0} {1}'.format(pending, name), file=file, color=cyan)

        def _print_skipped_test():
            if self.verbosity >= V_VERBOSE:
                message = StringIO()
                self.humanized_print('{0} {1}'.format(VowsReporter.SKIPPED, test['name']), file=message)
                message = message.getvalue().replace('\n', '')
                if test['skip'] != context['skip']:
                    message = '{0} (SKIPPED: {1})'.format(message, str(test['skip']))
                print(message, file=file)

        def _print_failed_test():
            ctx = test['context_instance']

            def _print_traceback():
                self.indent += 2

                ### NOTE:
                ###     Commented out try/except; potential debugging hinderance

                #try:

                traceback_args = (test['error']['type'],
                                  test['error']['value'],
                                  test['error']['traceback'])
                self.print_traceback(*traceback_args, file=file)

                # except Exception:
                #     # should never occur!
                #     err_msg = '''Unexpected error in PyVows!
                #                  PyVows error occurred in: ({0!s})
                #                  Context was: {1!r}
                #
                #               '''
                #     # from os.path import abspath
                #     raise VowsInternalError(err_msg, 'pyvows.reporting.test', ctx)

                # print file and line number
                if 'file' in test:
                    file_msg = 'found in {test[file]} at line {test[lineno]}'.format(test=test)
                    print('\n', self.indent_msg(red(file_msg)), '\n', file=file)

                self.indent -= 2

            self.humanized_print('{0} {test}'.format(VowsReporter.BROKEN, test=test['name']), file=file)

            # print generated topic (if applicable)
            if ctx.generated_topic:
                value = yellow(test['topic'])
                self.humanized_print('', file=file)
                self.humanized_print('\tTopic value:', file=file)
                self.humanized_print('\t{value}'.format(value=value), file=file)
                self.humanized_print('\n' * 2, file=file)

            # print traceback
            _print_traceback()

        # Show any error raised by the setup, topic or teardown functions
        if context.get('error', None):
            e = context['error']
            print('\n', self.indent_msg(blue("Error in {0!s}:".format(e.source))), file=file)
            self.print_traceback(*e.exc_info, file=file)

        else:
            for test in context['tests']:
                if VowsResult.test_is_successful(test):
                    _print_successful_test()
                elif test['pending']:
                    _print_pending_test()
                elif test['skip']:
                    _print_skipped_test()
                else:
                    _print_failed_test()

        # I hereby (re)curse you...!
        for context in context['contexts']:
            self.print_context(context['name'], context, file=file)

        self.indent -= 1
コード例 #13
0
ファイル: 64_vows.py プロジェクト: ricklupton/pyvows
 def topic(self):
     v = VowsTestReporter(VowsResult(), 0)
     v.humanized_print = lambda a: None
     return v