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


Python DebugControl.without_callers方法代码示例

本文整理汇总了Python中coverage.debug.DebugControl.without_callers方法的典型用法代码示例。如果您正苦于以下问题:Python DebugControl.without_callers方法的具体用法?Python DebugControl.without_callers怎么用?Python DebugControl.without_callers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coverage.debug.DebugControl的用法示例。


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

示例1: Coverage

# 需要导入模块: from coverage.debug import DebugControl [as 别名]
# 或者: from coverage.debug.DebugControl import without_callers [as 别名]

#.........这里部分代码省略.........
            # When testing, we use PyContracts, which should be considered
            # part of coverage.py, and it uses six. Exclude those directories
            # just as we exclude ourselves.
            import contracts
            import six
            for mod in [contracts, six]:
                self.cover_paths.append(self._canonical_path(mod))

        # Set the reporting precision.
        Numbers.set_precision(self.config.precision)

        atexit.register(self._atexit)

        # Create the matchers we need for _should_trace
        if self.source or self.source_pkgs:
            self.source_match = TreeMatcher(self.source)
            self.source_pkgs_match = ModuleMatcher(self.source_pkgs)
        else:
            if self.cover_paths:
                self.cover_match = TreeMatcher(self.cover_paths)
            if self.pylib_paths:
                self.pylib_match = TreeMatcher(self.pylib_paths)
        if self.include:
            self.include_match = FnmatchMatcher(self.include)
        if self.omit:
            self.omit_match = FnmatchMatcher(self.omit)

        # The user may want to debug things, show info if desired.
        self._write_startup_debug()

    def _write_startup_debug(self):
        """Write out debug info at startup if needed."""
        wrote_any = False
        with self.debug.without_callers():
            if self.debug.should('config'):
                config_info = sorted(self.config.__dict__.items())
                write_formatted_info(self.debug, "config", config_info)
                wrote_any = True

            if self.debug.should('sys'):
                write_formatted_info(self.debug, "sys", self.sys_info())
                for plugin in self.plugins:
                    header = "sys: " + plugin._coverage_plugin_name
                    info = plugin.sys_info()
                    write_formatted_info(self.debug, header, info)
                wrote_any = True

        if wrote_any:
            write_formatted_info(self.debug, "end", ())

    def _canonical_path(self, morf, directory=False):
        """Return the canonical path of the module or file `morf`.

        If the module is a package, then return its directory. If it is a
        module, then return its file, unless `directory` is True, in which
        case return its enclosing directory.

        """
        morf_path = PythonFileReporter(morf, self).filename
        if morf_path.endswith("__init__.py") or directory:
            morf_path = os.path.split(morf_path)[0]
        return morf_path

    def _name_for_module(self, module_globals, filename):
        """Get the name of the module for a set of globals and file name.
开发者ID:marcosptf,项目名称:fedora,代码行数:69,代码来源:control.py

示例2: Coverage

# 需要导入模块: from coverage.debug import DebugControl [as 别名]
# 或者: from coverage.debug.DebugControl import without_callers [as 别名]

#.........这里部分代码省略.........

        self._inited = True

        # Create and configure the debugging controller. COVERAGE_DEBUG_FILE
        # is an environment variable, the name of a file to append debug logs
        # to.
        self._debug = DebugControl(self.config.debug, self._debug_file)

        # _exclude_re is a dict that maps exclusion list names to compiled regexes.
        self._exclude_re = {}

        set_relative_directory()

        # Load plugins
        self._plugins = Plugins.load_plugins(self.config.plugins, self.config, self._debug)

        # Run configuring plugins.
        for plugin in self._plugins.configurers:
            # We need an object with set_option and get_option. Either self or
            # self.config will do. Choosing randomly stops people from doing
            # other things with those objects, against the public API.  Yes,
            # this is a bit childish. :)
            plugin.configure([self, self.config][int(time.time()) % 2])

    def _post_init(self):
        """Stuff to do after everything is initialized."""
        if not self._wrote_debug:
            self._wrote_debug = True
            self._write_startup_debug()

    def _write_startup_debug(self):
        """Write out debug info at startup if needed."""
        wrote_any = False
        with self._debug.without_callers():
            if self._debug.should('config'):
                config_info = sorted(self.config.__dict__.items())
                config_info = [(k, v) for k, v in config_info if not k.startswith('_')]
                write_formatted_info(self._debug, "config", config_info)
                wrote_any = True

            if self._debug.should('sys'):
                write_formatted_info(self._debug, "sys", self.sys_info())
                for plugin in self._plugins:
                    header = "sys: " + plugin._coverage_plugin_name
                    info = plugin.sys_info()
                    write_formatted_info(self._debug, header, info)
                wrote_any = True

        if wrote_any:
            write_formatted_info(self._debug, "end", ())

    def _should_trace(self, filename, frame):
        """Decide whether to trace execution in `filename`.

        Calls `_should_trace_internal`, and returns the FileDisposition.

        """
        disp = self._inorout.should_trace(filename, frame)
        if self._debug.should('trace'):
            self._debug.write(disposition_debug_msg(disp))
        return disp

    def _check_include_omit_etc(self, filename, frame):
        """Check a file name against the include/omit/etc, rules, verbosely.

        Returns a boolean: True if the file should be traced, False if not.
开发者ID:hugovk,项目名称:coveragepy,代码行数:70,代码来源:control.py


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