當前位置: 首頁>>代碼示例>>Python>>正文


Python Coverage.get_data方法代碼示例

本文整理匯總了Python中coverage.Coverage.get_data方法的典型用法代碼示例。如果您正苦於以下問題:Python Coverage.get_data方法的具體用法?Python Coverage.get_data怎麽用?Python Coverage.get_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在coverage.Coverage的用法示例。


在下文中一共展示了Coverage.get_data方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_coverage

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import get_data [as 別名]
    def run_coverage(self, test_name):
        cov = Coverage(source=self.config.source, omit=self.config.omit)
        cov.start()
        self.map_test(test_name)
        cov.stop()

        return cov.get_data()
開發者ID:emintham,項目名稱:codemon,代碼行數:9,代碼來源:codemon.py

示例2: AutotestConfig

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import get_data [as 別名]
class AutotestConfig(AppConfig):
    name = 'autotest'

    def __init__(self, *args, **kwargs):
        super(AutotestConfig, self).__init__(*args, **kwargs)
        self.coverage = None

    def coverage_start(self):
        if coverage and not self.coverage:
            self.coverage = Coverage()
            self.coverage.start()
            return self.coverage

    def coverage_report(self):
        if coverage and self.coverage:
            self.coverage.stop()
            coverage.stop()
            self.coverage.get_data().update(coverage.get_data())
            self.coverage.html_report()
開發者ID:doctormo,項目名稱:django-autotest,代碼行數:21,代碼來源:app.py

示例3: test_does_not_trace_files_outside_inclusion

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import get_data [as 別名]
def test_does_not_trace_files_outside_inclusion(tmpdir, branch, timid):
    @given(st.booleans())
    def test(a):
        rnd()

    cov = Coverage(
        config_file=False, data_file=str(tmpdir.join('.coverage')),
        branch=branch, timid=timid, include=[__file__],
    )
    cov._warn = escalate_warning
    cov.start()
    test()
    cov.stop()

    data = cov.get_data()
    assert len(list(data.measured_files())) == 1
開發者ID:doismellburning,項目名稱:hypothesis,代碼行數:18,代碼來源:test_coverage.py

示例4: test_achieves_full_coverage

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import get_data [as 別名]
def test_achieves_full_coverage(tmpdir, branch, timid):
    @given(st.booleans(), st.booleans(), st.booleans())
    def test(a, b, c):
        some_function_to_test(a, b, c)

    cov = Coverage(
        config_file=False, data_file=str(tmpdir.join('.coverage')),
        branch=branch, timid=timid,
    )
    cov._warn = escalate_warning
    cov.start()
    test()
    cov.stop()

    data = cov.get_data()
    lines = data.lines(__file__)
    for i in hrange(LINE_START + 1, LINE_END + 1):
        assert i in lines
開發者ID:doismellburning,項目名稱:hypothesis,代碼行數:20,代碼來源:test_coverage.py

示例5: CoverageScript

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import get_data [as 別名]

#.........這裏部分代碼省略.........
        return False

    def do_run(self, options, args):
        """Implementation of 'coverage run'."""

        if not args:
            if options.module:
                # Specified -m with nothing else.
                show_help("No module specified for -m")
                return ERR
            command_line = self.coverage.get_option("run:command_line")
            if command_line is not None:
                args = shlex.split(command_line)
                if args and args[0] == "-m":
                    options.module = True
                    args = args[1:]
        if not args:
            show_help("Nothing to do.")
            return ERR

        if options.append and self.coverage.get_option("run:parallel"):
            show_help("Can't append to data files in parallel mode.")
            return ERR

        if options.concurrency == "multiprocessing":
            # Can't set other run-affecting command line options with
            # multiprocessing.
            for opt_name in ['branch', 'include', 'omit', 'pylib', 'source', 'timid']:
                # As it happens, all of these options have no default, meaning
                # they will be None if they have not been specified.
                if getattr(options, opt_name) is not None:
                    show_help(
                        "Options affecting multiprocessing must only be specified "
                        "in a configuration file.\n"
                        "Remove --{} from the command line.".format(opt_name)
                    )
                    return ERR

        runner = PyRunner(args, as_module=bool(options.module))
        runner.prepare()

        if options.append:
            self.coverage.load()

        # Run the script.
        self.coverage.start()
        code_ran = True
        try:
            runner.run()
        except NoSource:
            code_ran = False
            raise
        finally:
            self.coverage.stop()
            if code_ran:
                self.coverage.save()

        return OK

    def do_debug(self, args):
        """Implementation of 'coverage debug'."""

        if not args:
            show_help("What information would you like: config, data, sys?")
            return ERR

        for info in args:
            if info == 'sys':
                sys_info = self.coverage.sys_info()
                print(info_header("sys"))
                for line in info_formatter(sys_info):
                    print(" %s" % line)
            elif info == 'data':
                self.coverage.load()
                data = self.coverage.get_data()
                print(info_header("data"))
                print("path: %s" % self.coverage.get_data().data_filename())
                if data:
                    print("has_arcs: %r" % data.has_arcs())
                    summary = line_counts(data, fullpath=True)
                    filenames = sorted(summary.keys())
                    print("\n%d files:" % len(filenames))
                    for f in filenames:
                        line = "%s: %d lines" % (f, summary[f])
                        plugin = data.file_tracer(f)
                        if plugin:
                            line += " [%s]" % plugin
                        print(line)
                else:
                    print("No data collected")
            elif info == 'config':
                print(info_header("config"))
                config_info = self.coverage.config.__dict__.items()
                for line in info_formatter(config_info):
                    print(" %s" % line)
            else:
                show_help("Don't know what you mean by %r" % info)
                return ERR

        return OK
開發者ID:hugovk,項目名稱:coveragepy,代碼行數:104,代碼來源:cmdline.py


注:本文中的coverage.Coverage.get_data方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。