当前位置: 首页>>代码示例>>Python>>正文


Python specter._函数代码示例

本文整理汇总了Python中specter._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: print_summary

    def print_summary(self):
        print(_('\n{0} Test(s) Executed!'.format(self.total)))

        if len(self.failed_tests) > 0:
            print(_('\nFailed test information:'))
            for wrapper in self.failed_tests:
                self.print_error(wrapper)
开发者ID:stackedsax,项目名称:Specter,代码行数:7,代码来源:dots.py

示例2: add_arguments

 def add_arguments(self, argparser):
     argparser.add_argument(
         '--show-all-expects', dest='show_all_expects', action='store_true',
         help=_('Displays all expectations for test cases'))
     argparser.add_argument(
         '--ascii-only', dest='ascii_only', action='store_true',
         help=_('Disables color and uses only ascii characters '
                '(useful for CI systems)'))
开发者ID:jmvrbanac,项目名称:Specter,代码行数:8,代码来源:console.py

示例3: setup_argparse

 def setup_argparse(self):
     self.arg_parser.add_argument(
         '--coverage', dest='coverage', action='store_true',
         help=_('Activates coverage.py integration'))
     self.arg_parser.add_argument(
         '--search', type=str, dest='search', metavar='',
         help=_('The spec suite folder path.'))
     self.arg_parser.add_argument(
         '--no-art', dest='no_art', action='store_true',
         help=_('Disables ASCII art'))
     self.arg_parser.add_argument(
         '--select-module', dest='select_module', metavar='',
         help=_('Selects a module path to run. '
                'Ex: spec.sample.TestClass'),
         default=None)
     self.arg_parser.add_argument(
         '--select-by-metadata', dest='select_meta', metavar='',
         help=_('Selects tests to run by specifying a list of '
                'key=value pairs you wish to run'),
         default=[], nargs='*')
     self.arg_parser.add_argument(
         '--no-color', dest='no_color', action='store_true',
         help=_('Disables all ASCII color codes.'))
     self.arg_parser.add_argument(
         '--xunit-results', dest='xunit_results', metavar='',
         help=_('Saves out xUnit compatible results to a specifed file'))
     self.arg_parser.add_argument(
         '--parallel', dest='parallel', action='store_true',
         help=_('Activate parallel testing mode'))
     self.arg_parser.add_argument(
         '--num-processes', dest='num_processes', default=6, metavar='',
         help=_('Specifies the number of processes to use under '
                'parallel mode (default: 6)'))
开发者ID:stackedsax,项目名称:Specter,代码行数:33,代码来源:runner.py

示例4: raise_a

    def raise_a(self, exception):
        self.expected = exception
        self.actions.extend(['raise', exception])
        condition = False

        try:
            self.target(*self.caller_args)
        except Exception as e:
            condition = True and type(e) is exception

        self.success = condition if not self.used_negative else not condition

        if not self.success:
            was = 'wasn\'t' if self.used_negative else 'was'

            # Make sure we have a name to use
            if hasattr(self.expected, '__name__'):
                name = self.expected.__name__
            else:
                name = type(self.expected).__name__

            msg = _(
                'function {func_name} {was} expected to raise "{exc}"'.format(
                    func_name=self.target_src_param,
                    exc=name,
                    was=was
                )
            )
            self.custom_msg = msg
开发者ID:pglass,项目名称:Specter,代码行数:29,代码来源:expect.py

示例5: print_param

 def print_param(value, param, indent, prefix):
     if not expect.success and not hardcoded(param):
         msg_list = str(value).splitlines() or ['']
         prefix = _('{0}: {1}').format(param or prefix, msg_list[0])
         print_indent_msg(prefix, indent)
         if len(msg_list) > 1:
             print_msg_list(msg_list[1:], indent)
开发者ID:stackedsax,项目名称:Specter,代码行数:7,代码来源:console.py

示例6: run

    def run(self, args):
        select_meta = None
        self.arguments = self.arg_parser.parse_args(args)

        self.reporter_manager = ReporterPluginManager()

        # Let each reporter parse cli arguments
        self.reporter_manager.process_arguments(self.arguments)

        if self.arguments.parallel:
            self.parallel_manager = ParallelManager(
                num_processes=self.arguments.num_processes,
                track_coverage=self.arguments.coverage,
                coverage_omit=self.get_coverage_omit_list())

        if self.arguments.select_meta:
            metas = [meta.split('=') for meta in self.arguments.select_meta]
            select_meta = {meta[0]: meta[1].strip('"\'') for meta in metas}

        if not self.arguments.no_art:
            print(self.generate_ascii_art())

        if self.arguments.coverage:
            print(_(' - Running with coverage enabled - '))
            self.coverage = coverage(omit=self.get_coverage_omit_list(),
                                     data_suffix=self.arguments.parallel)
            self.coverage._warn_no_data = False
            self.coverage.start()

        self.suite_types = self.suite_scanner.scan(
            search_path=self.arguments.search,
            module_name=self.arguments.select_module)

        # Serial: Add and Execute | Parallel: Collect all with the add process
        for suite_type in self.suite_types:

            suite = suite_type()
            self.suites.append(suite)
            self.reporter_manager.subscribe_all_to_describe(suite)
            suite.execute(select_metadata=select_meta,
                          parallel_manager=self.parallel_manager)

        # Actually execute the tests for parallel now
        if self.arguments.parallel:
            self.parallel_manager.execute_all()

        # Save coverage data if enabled
        if self.coverage:
            self.coverage.stop()
            self.coverage.save()
            if self.arguments.parallel:
                self.coverage.combine()

        # Print all console summaries
        for reporter in self.reporter_manager.get_console_reporters():
            reporter.print_summary()

        self.reporter_manager.finish_all()
        self.suite_scanner.destroy()
开发者ID:stackedsax,项目名称:Specter,代码行数:59,代码来源:runner.py

示例7: almost_equal

    def almost_equal(self, expected, places=7):
        if not isinstance(places, int):
            raise TypeError('Places must be an integer')

        self._compare(
            action_name=_('almost equal'),
            expected=expected,
            condition=round(abs(self.target - expected), places) == 0
        )
开发者ID:GrandPubba,项目名称:Specter,代码行数:9,代码来源:expect.py

示例8: _add_expect_to_wrapper

def _add_expect_to_wrapper(obj_to_add):
    try:
        for frame in inspect.stack():
            if frame[3] == 'execute':
                wrapper = frame[0].f_locals.get('self')
                if type(wrapper) is CaseWrapper:
                    wrapper.expects.append(obj_to_add)
    except Exception as error:
        raise Exception(_('Error attempting to add expect to parent '
                        'wrapper: {err}').format(err=error))
开发者ID:jfwood,项目名称:Specter,代码行数:10,代码来源:expect.py

示例9: __init__

 def __init__(self, target, required=False, src_params=None):
     super(ExpectAssert, self).__init__()
     self.prefix = _('expect')
     self.target = target
     self.target_src_param = src_params[0] if src_params else None
     self.expected_src_param = src_params[1] if src_params else None
     self.actions = [target]
     self.success = False
     self.used_negative = False
     self.required = required
开发者ID:jfwood,项目名称:Specter,代码行数:10,代码来源:expect.py

示例10: run

    def run(self, args):
        select_meta = None
        self.arguments = self.arg_parser.parse_args(args)

        # Let each reporter parse cli arguments
        self.reporter_manager.process_arguments(self.arguments)

        if self.arguments.select_meta:
            metas = [meta.split('=') for meta in self.arguments.select_meta]
            select_meta = {meta[0]: meta[1].strip('"\'') for meta in metas}

        if not self.arguments.no_art:
            print(self.generate_ascii_art())

        if self.arguments.coverage:
            print(_(' - Running with coverage enabled - '))
            self.coverage = coverage(omit=['*/pyevents/event.py',
                                           '*/pyevents/manager.py',
                                           '*/specter/spec.py',
                                           '*/specter/expect.py',
                                           '*/specter/reporting/__init__.py',
                                           '*/specter/reporting/console.py',
                                           '*/specter/__init__.py'])
            self.coverage._warn_no_data = False

        self.suite_types = self.suite_scanner.scan(
            search_path=self.arguments.search,
            module_name=self.arguments.select_module)

        for suite_type in self.suite_types:
            # Start Coverage Capture
            if self.coverage:
                self.coverage.start()

            suite = suite_type()
            self.suites.append(suite)
            self.reporter_manager.subscribe_all_to_describe(suite)
            suite.execute(select_metadata=select_meta)

            # Start Coverage Capture
            if self.coverage:
                self.coverage.stop()

        # Save coverage data if enabled
        if self.coverage:
            self.coverage.save()

        # Print all console summaries
        for reporter in self.reporter_manager.get_console_reporters():
            reporter.print_summary()

        self.reporter_manager.finish_all()
        self.suite_scanner.destroy()
开发者ID:jfwood,项目名称:Specter,代码行数:53,代码来源:runner.py

示例11: generate_ascii_art

 def generate_ascii_art(self):
     tag_line = _('Keeping the boogy man away from your code!')
     ascii_art = """
       ___
     _/ @@\\
 ~- ( \\  O/__     Specter
 ~-  \\    \\__)   ~~~~~~~~~~
 ~-  /     \\     {tag}
 ~- /      _\\
    ~~~~~~~~~
 """.format(tag=tag_line)
     return ascii_art
开发者ID:jfwood,项目名称:Specter,代码行数:12,代码来源:runner.py

示例12: __init__

 def __init__(self, target, required=False, src_params=None,
              caller_args=[]):
     super(ExpectAssert, self).__init__()
     self.prefix = _('expect')
     self.target = target
     self.src_params = src_params
     self.actions = [target]
     self.success = False
     self.used_negative = False
     self.required = required
     self.caller_args = caller_args
     self.custom_msg = None
     self.custom_report_vars = {}
开发者ID:GrandPubba,项目名称:Specter,代码行数:13,代码来源:expect.py

示例13: raise_a

    def raise_a(self, exception):
        self.expected = exception
        self.actions.extend(['raise', exception])
        condition = False
        raised_exc = 'nothing'

        try:
            self.target(*self.caller_args)
        except Exception as e:
            condition = type(e) == exception
            raised_exc = e

        # We didn't raise anything
        if self.used_negative and not isinstance(raised_exc, Exception):
            self.success = True

        # Raised, but it didn't match
        elif self.used_negative and type(raised_exc) != exception:
            self.success = False

        elif self.used_negative:
            self.success = not condition

        else:
            self.success = condition

        if not self.success:
            was = 'wasn\'t' if self.used_negative else 'was'

            # Make sure we have a name to use
            if hasattr(self.expected, '__name__'):
                name = self.expected.__name__
            else:
                name = type(self.expected).__name__

            msg = _('function {func_name} {was} expected to raise "{exc}".')
            self.custom_msg = msg.format(
                func_name=self.target_src_param,
                exc=name,
                was=was
            )
            self.custom_report_vars['Raised Exception'] = (
                type(raised_exc).__name__
            )
开发者ID:GrandPubba,项目名称:Specter,代码行数:44,代码来源:expect.py

示例14: raise_a

    def raise_a(self, exception):
        self.expected = exception
        self.actions.extend(['raise', exception])
        condition = False

        try:
            self.target(*self.caller_args)
        except Exception as e:
            condition = True and type(e) is exception

        self.success = condition if not self.used_negative else not condition

        if not self.success:
            was = 'wasn\'t' if self.used_negative else 'was'
            msg = _('Function {func_name} {was} expected to raise "{excpt}"'
                    ''.format(func_name=self.target_src_param,
                              excpt=self.expected.__name__,
                              was=was))
            self.custom_msg = msg
开发者ID:stackedsax,项目名称:Specter,代码行数:19,代码来源:expect.py

示例15: setup_argparse

 def setup_argparse(self):
     self.arg_parser.add_argument(
         '--coverage', dest='coverage', action='store_true',
         help=_('Activates coverage.py integration'))
     self.arg_parser.add_argument(
         '--search', type=str, dest='search',
         help=_('The spec suite folder path.'))
     self.arg_parser.add_argument(
         '--no-art', dest='no_art', action='store_true',
         help=_('Disables ASCII art'))
     self.arg_parser.add_argument(
         '--select-module', dest='select_module',
         help=_('Selects a module path to run. '
                'Ex: spec.sample.TestClass'),
         default=None)
     self.arg_parser.add_argument(
         '--select-by-metadata', dest='select_meta',
         help=_('Selects tests to run by specifying a list of '
                'key=value pairs you wish to run'),
         default=[], nargs='*')
     self.arg_parser.add_argument(
         '--no-color', dest='no_color', action='store_true',
         help=_('Disables all ASCII color codes.'))
开发者ID:jfwood,项目名称:Specter,代码行数:23,代码来源:runner.py


注:本文中的specter._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。