本文整理汇总了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()
示例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()
示例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
示例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
示例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