本文整理汇总了Python中coverage.Coverage.load方法的典型用法代码示例。如果您正苦于以下问题:Python Coverage.load方法的具体用法?Python Coverage.load怎么用?Python Coverage.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coverage.Coverage
的用法示例。
在下文中一共展示了Coverage.load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import load [as 别名]
def run(self, edit):
view = self.view
view.erase_regions('SublimePythonCoverage')
fname = view.file_name()
if not fname or not fname.endswith('.py'):
return
cov_file = find(fname, '.coverage')
if not cov_file:
print('No .coverage file found near %s' % fname)
return
else:
print('Reading coverage data from %s' % cov_file)
config_file = os.path.join(os.path.dirname(cov_file), '.coveragerc')
if find(fname, '.coverage-noisy'):
flags = sublime.DRAW_EMPTY | sublime.DRAW_OUTLINED
else:
flags = sublime.HIDDEN
# run analysis and find uncovered lines
cov = Coverage(data_file=cov_file, config_file=config_file)
outlines = []
cov.load()
if not cov.omit or not FnmatchMatcher(cov.omit).match(fname):
f, s, excluded, missing, m = cov.analysis2(fname)
for line in missing:
outlines.append(view.full_line(view.text_point(line - 1, 0)))
# update highlighted regions
view.add_regions('SublimePythonCoverage', outlines,
'coverage.missing', 'bookmark', flags)
示例2: CodeCoverage
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import load [as 别名]
class CodeCoverage(object):
"""
Code Coverage radish extension
"""
OPTIONS = [
("--with-coverage", "enable code coverage"),
("--cover-packages=<cover_packages>", "specify source code package")
]
LOAD_IF = staticmethod(lambda config: config.with_coverage)
LOAD_PRIORITY = 70
def __init__(self):
before.all(self.coverage_start)
after.all(self.coverage_stop)
if world.config.cover_packages:
cover_packages = world.config.cover_packages.split(",")
else:
cover_packages = []
self.coverage = Coverage(source=cover_packages)
def coverage_start(self, features, marker):
"""
Start the coverage measurement
"""
self.coverage.load()
self.coverage.start()
def coverage_stop(self, features, marker):
"""
Stop the coverage measurement
and create report
"""
self.coverage.stop()
self.coverage.save()
self.coverage.report(file=sys.stdout)
示例3: get_cov
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import load [as 别名]
def get_cov(input_file):
cov = Coverage(data_file=input_file)
cov.load()
return cov
示例4: Coverage
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import load [as 别名]
# usage:
# run_tests.py [PYTEST_ARGS]
import os
import subprocess
import sys
from coverage import Coverage
SHELL = sys.platform == 'win32'
if __name__ == '__main__':
command = ['py.test']
if os.environ.get('WITH_COVERAGE') == '1':
command.extend(['--cov=rinoh', '--cov-report='])
if os.environ.get('BASETEMP'):
command.append('--basetemp={}'.format(os.environ['BASETEMP']))
command.extend(sys.argv[1:])
rc = subprocess.call(command, shell=SHELL)
if os.environ.get('WITH_COVERAGE') == '1':
cov = Coverage()
cov.load()
cov.combine()
cov.report(skip_covered=True)
cov.xml_report()
raise SystemExit(rc)
示例5: CoverageScript
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import load [as 别名]
class CoverageScript(object):
"""The command-line interface to coverage.py."""
def __init__(self):
self.global_option = False
self.coverage = None
def command_line(self, argv):
"""The bulk of the command line interface to coverage.py.
`argv` is the argument list to process.
Returns 0 if all is well, 1 if something went wrong.
"""
# Collect the command-line options.
if not argv:
show_help(topic='minimum_help')
return OK
# The command syntax we parse depends on the first argument. Global
# switch syntax always starts with an option.
self.global_option = argv[0].startswith('-')
if self.global_option:
parser = GlobalOptionParser()
else:
parser = CMDS.get(argv[0])
if not parser:
show_help("Unknown command: '%s'" % argv[0])
return ERR
argv = argv[1:]
ok, options, args = parser.parse_args_ok(argv)
if not ok:
return ERR
# Handle help and version.
if self.do_help(options, args, parser):
return OK
# Listify the list options.
source = unshell_list(options.source)
omit = unshell_list(options.omit)
include = unshell_list(options.include)
debug = unshell_list(options.debug)
# Do something.
self.coverage = Coverage(
data_suffix=options.parallel_mode,
cover_pylib=options.pylib,
timid=options.timid,
branch=options.branch,
config_file=options.rcfile,
source=source,
omit=omit,
include=include,
debug=debug,
concurrency=options.concurrency,
check_preimported=True,
context=options.context,
)
if options.action == "debug":
return self.do_debug(args)
elif options.action == "erase":
self.coverage.erase()
return OK
elif options.action == "run":
return self.do_run(options, args)
elif options.action == "combine":
if options.append:
self.coverage.load()
data_dirs = args or None
self.coverage.combine(data_dirs, strict=True)
self.coverage.save()
return OK
# Remaining actions are reporting, with some common options.
report_args = dict(
morfs=unglob_args(args),
ignore_errors=options.ignore_errors,
omit=omit,
include=include,
)
# We need to be able to import from the current directory, because
# plugins may try to, for example, to read Django settings.
sys.path.insert(0, '')
self.coverage.load()
total = None
if options.action == "report":
total = self.coverage.report(
show_missing=options.show_missing,
skip_covered=options.skip_covered,
**report_args
#.........这里部分代码省略.........