本文整理汇总了Python中coverage.Coverage.html_report方法的典型用法代码示例。如果您正苦于以下问题:Python Coverage.html_report方法的具体用法?Python Coverage.html_report怎么用?Python Coverage.html_report使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coverage.Coverage
的用法示例。
在下文中一共展示了Coverage.html_report方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [as 别名]
def run(self):
from coverage import Coverage
cov = Coverage(source=self.distribution.packages)
cov.start()
super().run()
cov.stop()
cov.xml_report()
cov.html_report()
示例2: run
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [as 别名]
def run(self):
import pytest
cov = Coverage()
cov.erase()
cov.start()
result = pytest.main()
cov.stop()
cov.save()
cov.html_report(directory="covhtml")
sys.exit(int(bool(len(result.failures) > 0 or len(result.errors) > 0)))
示例3: run_test_suite
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [as 别名]
def run_test_suite():
cov = Coverage(config_file=True)
cov.erase()
cov.start()
# Announce the test suite
sys.stdout.write(colored(text="\nWelcome to the ", color="magenta", attrs=["bold"]))
sys.stdout.write(colored(text="python-doc-inherit", color="green", attrs=["bold"]))
sys.stdout.write(colored(text=" test suite.\n\n", color="magenta", attrs=["bold"]))
# Announce test run
print(colored(text="Step 1: Running unit tests.\n", color="yellow", attrs=["bold"]))
test_suite = TestLoader().discover(str(Path("tests").absolute()))
result = TextTestRunner(verbosity=1).run(test_suite)
if not result.wasSuccessful():
sys.exit(len(result.failures) + len(result.errors))
# Announce coverage run
print(colored(text="\nStep 2: Generating coverage results.\n", color="yellow", attrs=["bold"]))
cov.stop()
percentage = round(cov.report(show_missing=True), 2)
cov.html_report(directory='cover')
cov.save()
if percentage < TESTS_THRESHOLD:
print(colored(text="YOUR CHANGES HAVE CAUSED TEST COVERAGE TO DROP. " +
"WAS {old}%, IS NOW {new}%.\n".format(old=TESTS_THRESHOLD, new=percentage),
color="red", attrs=["bold"]))
sys.exit(1)
# Announce flake8 run
sys.stdout.write(colored(text="\nStep 3: Checking for pep8 errors.\n\n", color="yellow", attrs=["bold"]))
print("pep8 errors:")
print("----------------------------------------------------------------------")
from subprocess import call
flake_result = call(["flake8", ".", "--count"])
if flake_result != 0:
print("pep8 errors detected.")
print(colored(text="\nYOUR CHANGES HAVE INTRODUCED PEP8 ERRORS!\n", color="red", attrs=["bold"]))
sys.exit(flake_result)
else:
print("None")
# Announce success
print(colored(text="\nTests completed successfully with no errors. Congrats!", color="green", attrs=["bold"]))
示例4: with_coverage
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [as 别名]
def with_coverage(f, source, *, report=True, data=False):
cov = Coverage(source=[source])
cov.start()
try:
exit_code = f()
finally:
cov.stop()
if not exit_code:
if report:
print() # Print blank line.
cov.report(show_missing=False)
cov.html_report()
if data:
cov.save()
return exit_code
示例5: AutotestConfig
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [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()
示例6: main
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [as 别名]
def main():
""" The main function, mainly functioning to do the main functional work
(thanks pylint)
"""
if len(sys.argv) > 1 and sys.argv[1] == 'cover':
# FIXME - there are enough args now to need an arg parser
cover = Coverage(branch=True, auto_data=True)
min_percent = 0
if len(sys.argv) > 2:
min_percent = float(sys.argv[2])
else:
cover = False
loader = unittest.defaultTestLoader
runner = unittest.TextTestRunner(verbosity=2)
if cover:
cover.erase()
cover.start()
tests = loader.discover('.')
tests_lib = loader.discover('lib', top_level_dir='lib')
tests.addTests(tests_lib)
result = runner.run(tests)
if cover:
cover.stop()
# the debian coverage package didnt include jquery.debounce.min.js
# (and additionally, that thing is not packaged for debian elsewhere)
try:
cover.html_report()
except:
pass
percent = cover.report(show_missing=True)
if min_percent > percent:
print("The coverage ({:.1f}% reached) fails to reach the "
"minimum required ({}%)\n".format(percent, min_percent))
exit(1)
if not result.wasSuccessful():
exit(1)
示例7: run_test_suite
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [as 别名]
#.........这里部分代码省略.........
},
DJSTRIPE_PLAN_HIERARCHY = {
"bronze": {
"level": 1,
"plans": [
"test0",
"test",
]
},
"silver": {
"level": 2,
"plans": [
"test2",
"test_deletion",
]
},
"gold": {
"level": 3,
"plans": [
"test_trial",
"unidentified_test_plan",
]
},
},
DJSTRIPE_SUBSCRIPTION_REQUIRED_EXCEPTION_URLS=(
"(admin)",
"test_url_name",
"testapp_namespaced:test_url_namespaced",
),
)
# Avoid AppRegistryNotReady exception
# http://stackoverflow.com/questions/24793351/django-appregistrynotready
if hasattr(django, "setup"):
django.setup()
# Announce the test suite
sys.stdout.write(colored(text="\nWelcome to the ", color="magenta", attrs=["bold"]))
sys.stdout.write(colored(text="dj-stripe", color="green", attrs=["bold"]))
sys.stdout.write(colored(text=" test suite.\n\n", color="magenta", attrs=["bold"]))
# Announce test run
sys.stdout.write(colored(text="Step 1: Running unit tests.\n\n", color="yellow", attrs=["bold"]))
# Hack to reset the global argv before nose has a chance to grab it
# http://stackoverflow.com/a/1718407/1834570
args = sys.argv[1:]
sys.argv = sys.argv[0:1]
from django_nose import NoseTestSuiteRunner
test_runner = NoseTestSuiteRunner(verbosity=1)
failures = test_runner.run_tests(["."])
if failures:
sys.exit(failures)
if enable_coverage:
# Announce coverage run
sys.stdout.write(colored(text="\nStep 2: Generating coverage results.\n\n", color="yellow", attrs=["bold"]))
cov.stop()
percentage = round(cov.report(show_missing=True), 2)
cov.html_report(directory='cover')
cov.save()
if percentage < TESTS_THRESHOLD:
sys.stderr.write(colored(text="YOUR CHANGES HAVE CAUSED TEST COVERAGE TO DROP. " +
"WAS {old}%, IS NOW {new}%.\n\n".format(old=TESTS_THRESHOLD, new=percentage),
color="red", attrs=["bold"]))
sys.exit(1)
else:
# Announce disabled coverage run
sys.stdout.write(colored(text="\nStep 2: Generating coverage results [SKIPPED].", color="yellow", attrs=["bold"]))
if enable_pep8:
# Announce flake8 run
sys.stdout.write(colored(text="\nStep 3: Checking for pep8 errors.\n\n", color="yellow", attrs=["bold"]))
print("pep8 errors:")
print("----------------------------------------------------------------------")
from subprocess import call
flake_result = call(["flake8", ".", "--count"])
if flake_result != 0:
sys.stderr.write("pep8 errors detected.\n")
sys.stderr.write(colored(text="\nYOUR CHANGES HAVE INTRODUCED PEP8 ERRORS!\n\n", color="red", attrs=["bold"]))
sys.exit(flake_result)
else:
print("None")
else:
# Announce disabled coverage run
sys.stdout.write(colored(text="\nStep 3: Checking for pep8 errors [SKIPPED].\n", color="yellow", attrs=["bold"]))
# Announce success
if enable_coverage and enable_pep8:
sys.stdout.write(colored(text="\nTests completed successfully with no errors. Congrats!\n", color="green", attrs=["bold"]))
else:
sys.stdout.write(colored(text="\nTests completed successfully, but some step(s) were skipped!\n", color="green", attrs=["bold"]))
sys.stdout.write(colored(text="Don't push without running the skipped step(s).\n", color="red", attrs=["bold"]))
示例8: Decide
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [as 别名]
smach.StateMachine.add('Timeout3',Timeout(), transitions={'outcome1':'Discard'})
#Decide what to do
smach.StateMachine.add('Decide', Decide(), transitions={'outcome1':'Release','outcome2':'Discard'})
#Release piece
smach.StateMachine.add('Release', Release(), transitions={'outcome1':'Receive1','outcome2':'tableDone'})
#Discard piece
smach.StateMachine.add('Discard', Discard(), transitions={'outcome1':'Receive1','outcome2':'tableDone'})
# Execute SMACH plan
outcome = sm.execute()
#---------------------------------------------------------------------------------------------------
if __name__ == '__main__':
cov = Coverage()
cov.start()
try:
main(sys.argv[1])
cov.stop()
cov.html_report(directory='covhtml')
except rospy.ROSInterruptException: #to stop the code when pressing Ctr+c
cov.stop()
cov.save()
cov.report_html()
pass
示例9: run_test_suite
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [as 别名]
#.........这里部分代码省略.........
"price": 2500, # $25.00
"currency": "usd",
"interval": "month"
},
"test2": {
"stripe_plan_id": "test_id_2",
"name": "Test Plan 2",
"description": "Yet Another test plan",
"price": 5000, # $50.00
"currency": "usd",
"interval": "month"
},
"test_deletion": {
"stripe_plan_id": "test_id_3",
"name": "Test Plan 3",
"description": "Test plan for deletion.",
"price": 5000, # $50.00
"currency": "usd",
"interval": "month"
},
"test_trial": {
"stripe_plan_id": "test_id_4",
"name": "Test Plan 4",
"description": "Test plan for trails.",
"price": 7000, # $70.00
"currency": "usd",
"interval": "month",
"trial_period_days": 7
},
"unidentified_test_plan": {
"name": "Unidentified Test Plan",
"description": "A test plan with no ID.",
"price": 2500, # $25.00
"currency": "usd",
"interval": "month"
}
},
DJSTRIPE_SUBSCRIPTION_REQUIRED_EXCEPTION_URLS=(
"(admin)",
"test_url_name",
"testapp_namespaced:test_url_namespaced",
"fn:/test_fnmatch*"
),
DJSTRIPE_USE_NATIVE_JSONFIELD=os.environ.get("USE_NATIVE_JSONFIELD", "") == "1",
)
# Avoid AppRegistryNotReady exception
# http://stackoverflow.com/questions/24793351/django-appregistrynotready
if hasattr(django, "setup"):
django.setup()
# Announce the test suite
sys.stdout.write(colored(text="\nWelcome to the ", color="magenta", attrs=["bold"]))
sys.stdout.write(colored(text="dj-stripe", color="green", attrs=["bold"]))
sys.stdout.write(colored(text=" test suite.\n\n", color="magenta", attrs=["bold"]))
# Announce test run
sys.stdout.write(colored(text="Step 1: Running unit tests.\n\n", color="yellow", attrs=["bold"]))
# Hack to reset the global argv before nose has a chance to grab it
# http://stackoverflow.com/a/1718407/1834570
args = sys.argv[1:]
sys.argv = sys.argv[0:1]
from django_nose import NoseTestSuiteRunner
test_runner = NoseTestSuiteRunner(verbosity=1, keepdb=True, failfast=True)
failures = test_runner.run_tests(tests)
if failures:
sys.exit(failures)
if enable_coverage:
# Announce coverage run
sys.stdout.write(colored(text="\nStep 2: Generating coverage results.\n\n", color="yellow", attrs=["bold"]))
cov.stop()
percentage = round(cov.report(show_missing=True), 2)
cov.html_report(directory='cover')
cov.save()
if percentage < TESTS_THRESHOLD:
sys.stderr.write(colored(text="YOUR CHANGES HAVE CAUSED TEST COVERAGE TO DROP. " +
"WAS {old}%, IS NOW {new}%.\n\n".format(old=TESTS_THRESHOLD, new=percentage),
color="red", attrs=["bold"]))
sys.exit(1)
else:
# Announce disabled coverage run
sys.stdout.write(colored(text="\nStep 2: Generating coverage results [SKIPPED].",
color="yellow", attrs=["bold"]))
# Announce success
if enable_coverage:
sys.stdout.write(colored(text="\nTests completed successfully with no errors. Congrats!\n",
color="green", attrs=["bold"]))
else:
sys.stdout.write(colored(text="\nTests completed successfully, but some step(s) were skipped!\n",
color="green", attrs=["bold"]))
sys.stdout.write(colored(text="Don't push without running the skipped step(s).\n",
color="red", attrs=["bold"]))
示例10: __import__
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [as 别名]
mod = __import__(t, globals(), locals(), ['suite'])
suitefn = getattr(mod, 'suite')
suite.addTest(suitefn())
except (ImportError, AttributeError):
# else, just load all the test cases from the module.
suite.addTest(unittest.defaultTestLoader.loadTestsFromName(t))
runner = unittest.TextTestRunner()
cov.start()
result = runner.run(suite)
cov.stop()
if not result.wasSuccessful():
exit(3)
percent = round(cov.report(), 4)
cov.html_report()
if os.path.isfile('min_cov.txt'):
file = open('min_cov.txt', 'r')
min_coverage = float(file.read())
file.close()
if percent < min_coverage:
exit(2)
else:
file = open('min_cov.txt', 'w')
file.write(str(percent))
file.close()
else:
file = open('min_cov.txt', 'w')
file.write(str(percent))
file.close()
示例11: CoverageScript
# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import html_report [as 别名]
#.........这里部分代码省略.........
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
)
elif options.action == "annotate":
self.coverage.annotate(directory=options.directory, **report_args)
elif options.action == "html":
total = self.coverage.html_report(
directory=options.directory,
title=options.title,
skip_covered=options.skip_covered,
**report_args
)
elif options.action == "xml":
outfile = options.outfile
total = self.coverage.xml_report(outfile=outfile, **report_args)
if total is not None:
# Apply the command line fail-under options, and then use the config
# value, so we can get fail_under from the config file.
if options.fail_under is not None:
self.coverage.set_option("report:fail_under", options.fail_under)
fail_under = self.coverage.get_option("report:fail_under")
precision = self.coverage.get_option("report:precision")
if should_fail_under(total, fail_under, precision):
return FAIL_UNDER
return OK
def do_help(self, options, args, parser):
"""Deal with help requests.
Return True if it handled the request, False if not.
"""
# Handle help.
if options.help:
if self.global_option:
show_help(topic='help')