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


Python DebugControl.write_formatted_info方法代码示例

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


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

示例1: Coverage

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

#.........这里部分代码省略.........
        """Start measuring code coverage.

        Coverage measurement actually occurs in functions called after `start`
        is invoked.  Statements in the same scope as `start` won't be measured.

        Once you invoke `start`, you must also call `stop` eventually, or your
        process might not shut down cleanly.

        """
        if self.run_suffix:
            # Calling start() means we're running code, so use the run_suffix
            # as the data_suffix when we eventually save the data.
            self.data_suffix = self.run_suffix
        if self.auto_data:
            self.load()

        # Create the matchers we need for _should_trace
        if self.source or self.source_pkgs:
            self.source_match = TreeMatcher(self.source)
        else:
            if self.cover_dir:
                self.cover_match = TreeMatcher([self.cover_dir])
            if self.pylib_dirs:
                self.pylib_match = TreeMatcher(self.pylib_dirs)
        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.
        if self.debug.should('config'):
            self.debug.write("Configuration values:")
            config_info = sorted(self.config.__dict__.items())
            self.debug.write_formatted_info(config_info)

        if self.debug.should('sys'):
            self.debug.write("Debugging info:")
            self.debug.write_formatted_info(self.sysinfo())

        self.collector.start()
        self._started = True
        self._measured = True

    def stop(self):
        """Stop measuring code coverage."""
        self._started = False
        self.collector.stop()

    def _atexit(self):
        """Clean up on process shutdown."""
        if self._started:
            self.stop()
        if self.auto_data:
            self.save()

    def erase(self):
        """Erase previously-collected coverage data.

        This removes the in-memory data collected in this session as well as
        discarding the data file.

        """
        self.collector.reset()
        self.data.erase()

    def clear_exclude(self, which='exclude'):
开发者ID:fabio-ts,项目名称:unftt,代码行数:70,代码来源:control.py

示例2: Coverage

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

#.........这里部分代码省略.........
        if env.TESTING:
            # 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, six
            for mod in [contracts, six]:
                self.cover_dirs.append(self._canonical_dir(mod))

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

        atexit.register(self._atexit)

        self._inited = True

        # 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_dirs:
                self.cover_match = TreeMatcher(self.cover_dirs)
            if self.pylib_dirs:
                self.pylib_match = TreeMatcher(self.pylib_dirs)
        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.
        wrote_any = False
        if self.debug.should('config'):
            config_info = sorted(self.config.__dict__.items())
            self.debug.write_formatted_info("config", config_info)
            wrote_any = True

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

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

    def _canonical_dir(self, morf):
        """Return the canonical directory of the module or file `morf`."""
        morf_filename = PythonFileReporter(morf, self).filename
        return os.path.split(morf_filename)[0]

    def _source_for_file(self, filename):
        """Return the source file for `filename`.

        Given a file name being traced, return the best guess as to the source
        file to attribute it to.

        """
        if filename.endswith(".py"):
            # .py files are themselves source files.
            return filename

        elif filename.endswith((".pyc", ".pyo")):
            # Bytecode files probably have source files near them.
            py_filename = filename[:-1]
开发者ID:Athsheep,项目名称:Flask_Web_Development,代码行数:70,代码来源:control.py

示例3: coverage

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

#.........这里部分代码省略.........
                    self.source_match.add(pkg_file)
                else:
                    self._warn('Module %s has no Python source.' % pkg)

            for pkg in found:
                self.source_pkgs.remove(pkg)

    def use_cache(self, usecache):
        self.data.usefile(usecache)

    def load(self):
        self.collector.reset()
        self.data.read()

    def start(self):
        if self.run_suffix:
            self.data_suffix = self.run_suffix
        if self.auto_data:
            self.load()
        if self.source or self.source_pkgs:
            self.source_match = TreeMatcher(self.source)
        else:
            if self.cover_dir:
                self.cover_match = TreeMatcher([self.cover_dir])
            if self.pylib_dirs:
                self.pylib_match = TreeMatcher(self.pylib_dirs)
        if self.include:
            self.include_match = FnmatchMatcher(self.include)
        if self.omit:
            self.omit_match = FnmatchMatcher(self.omit)
        if self.debug.should('config'):
            self.debug.write('Configuration values:')
            config_info = sorted(self.config.__dict__.items())
            self.debug.write_formatted_info(config_info)
        if self.debug.should('sys'):
            self.debug.write('Debugging info:')
            self.debug.write_formatted_info(self.sysinfo())
        self.collector.start()
        self._started = True
        self._measured = True

    def stop(self):
        self._started = False
        self.collector.stop()

    def _atexit(self):
        if self._started:
            self.stop()
        if self.auto_data:
            self.save()

    def erase(self):
        self.collector.reset()
        self.data.erase()

    def clear_exclude(self, which = 'exclude'):
        setattr(self.config, which + '_list', [])
        self._exclude_regex_stale()

    def exclude(self, regex, which = 'exclude'):
        excl_list = getattr(self.config, which + '_list')
        excl_list.append(regex)
        self._exclude_regex_stale()

    def _exclude_regex_stale(self):
        self._exclude_re.clear()
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:70,代码来源:control.py


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