當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。