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


Python Coverage.save方法代码示例

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


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

示例1: run_tests

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
def run_tests(context, app=None, module=None, doctype=None, test=(),
	driver=None, profile=False, coverage=False, junit_xml_output=False, ui_tests = False,
	doctype_list_path=None, skip_test_records=False, skip_before_tests=False, failfast=False):

	"Run tests"
	import frappe.test_runner
	tests = test

	site = get_site(context)
	frappe.init(site=site)

	frappe.flags.skip_before_tests = skip_before_tests
	frappe.flags.skip_test_records = skip_test_records

	if coverage:
		# Generate coverage report only for app that is being tested
		source_path = os.path.join(get_bench_path(), 'apps', app or 'frappe')
		cov = Coverage(source=[source_path], omit=['*.html', '*.js', '*.css'])
		cov.start()

	ret = frappe.test_runner.main(app, module, doctype, context.verbose, tests=tests,
		force=context.force, profile=profile, junit_xml_output=junit_xml_output,
		ui_tests = ui_tests, doctype_list_path = doctype_list_path, failfast=failfast)

	if coverage:
		cov.stop()
		cov.save()

	if len(ret.failures) == 0 and len(ret.errors) == 0:
		ret = 0

	if os.environ.get('CI'):
		sys.exit(ret)
开发者ID:ESS-LLP,项目名称:frappe,代码行数:35,代码来源:utils.py

示例2: run_tests

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
    def run_tests(self):
        " Run coverage on unit test "
        # need to import here cause we are in a venv
        import six
        from coverage import Coverage

        coverage = Coverage()
        coverage.start()

        # Purge modules under test from sys.modules. The test loader will
        # re-import them from the build location. Required when 2to3 is used
        # with namespace packages.
        if six.PY3 and getattr(self.distribution, 'use_2to3', False):
            module = self.test_suite.split('.')[0]
            if module in _namespace_packages:
                del_modules = []
                if module in sys.modules:
                    del_modules.append(module)
                module += '.'
                for name in sys.modules:
                    if name.startswith(module):
                        del_modules.append(name)
                list(map(sys.modules.__delitem__, del_modules))

        unittest_main(
            None, None, self._argv,
            testLoader=self._resolve_as_ep(self.test_loader),
            testRunner=self._resolve_as_ep(self.test_runner),
            exit=False,
        )

        coverage.stop()
        coverage.save()
        coverage.report(show_missing=False)
开发者ID:aRkadeFR,项目名称:pymm,代码行数:36,代码来源:support.py

示例3: _bootstrap

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
 def _bootstrap(self):
     from coverage import Coverage
     cov = Coverage(data_suffix=True)
     cov.start()
     try:
         return original_bootstrap(self)
     finally:
         cov.stop()
         cov.save()
开发者ID:BLourence,项目名称:RemoteIR,代码行数:11,代码来源:monkey.py

示例4: _bootstrap

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
 def _bootstrap(self):
     """Wrapper around _bootstrap to start coverage."""
     from coverage import Coverage
     cov = Coverage(data_suffix=True)
     cov.start()
     try:
         return original_bootstrap(self)
     finally:
         cov.stop()
         cov.save()
开发者ID:mociepka,项目名称:coveragepy,代码行数:12,代码来源:monkey.py

示例5: _bootstrap

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
 def _bootstrap(self):
     """Wrapper around _bootstrap to start coverage."""
     from coverage import Coverage
     rcfile = getattr(multiprocessing, PATCHED_MARKER)
     cov = Coverage(data_suffix=True, config_file=rcfile)
     cov.start()
     try:
         return original_bootstrap(self)
     finally:
         cov.stop()
         cov.save()
开发者ID:iacopy,项目名称:coveragepy,代码行数:13,代码来源:multiproc.py

示例6: _bootstrap

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
 def _bootstrap(self):
     """Wrapper around _bootstrap to start coverage."""
     from coverage import Coverage       # avoid circular import
     rcfile = os.environ[COVERAGE_RCFILE_ENV]
     cov = Coverage(data_suffix=True, config_file=rcfile)
     cov.start()
     try:
         return original_bootstrap(self)
     finally:
         cov.stop()
         cov.save()
开发者ID:Aisling-Dempsey,项目名称:pencil_me_in,代码行数:13,代码来源:multiproc.py

示例7: run

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [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)))
开发者ID:cobbler,项目名称:cobbler,代码行数:15,代码来源:setup.py

示例8: _bootstrap

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
 def _bootstrap(self):
     """Wrapper around _bootstrap to start coverage."""
     from coverage import Coverage
     coverage_config = getattr(multiprocessing, PATCHED_MARKER)
     coverage_config.parallel = True
     cov = Coverage()
     cov.config = coverage_config
     cov.start()
     try:
         return original_bootstrap(self)
     finally:
         cov.stop()
         cov.save()
开发者ID:arcivanov,项目名称:pybuilder,代码行数:15,代码来源:coverage_utils.py

示例9: run_test_suite

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [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"]))
开发者ID:kavdev,项目名称:python-doc-inherit,代码行数:53,代码来源:runtests.py

示例10: with_coverage

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [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
开发者ID:nre,项目名称:Doxhooks,代码行数:17,代码来源:test_runner.py

示例11: main

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
def main():
    cov = Coverage(
        omit=[
            "*passlib*",
            "*test*",
            "*tornado*",
            "*backports_abc*",
            "*singledispatch*",
            "*six*",
            "*certifi*",
            "*daemon*",
            "*funcsigs*",
            "*mock*",
            "*pbr*",
            "*pkg_resources*",
            "*tablib*",
        ]
    )

    cov.start()

    from app_test import ApplicationTest
    from database_test import DatabaseTest
    from http_test import HTTPTestCase
    from procinfo_test import ProcInfoTest
    from user_test import UserTest
    from token_test import TokenTest
    from ws_test import WebSocketTestCase
    from unittest import TestLoader, TextTestRunner, TestSuite

    loader = TestLoader()
    suite = TestSuite(
        (
            loader.loadTestsFromTestCase(ProcInfoTest),
            loader.loadTestsFromTestCase(DatabaseTest),
            loader.loadTestsFromTestCase(UserTest),
            loader.loadTestsFromTestCase(TokenTest),
            loader.loadTestsFromTestCase(HTTPTestCase),
            loader.loadTestsFromTestCase(WebSocketTestCase),
            loader.loadTestsFromTestCase(ApplicationTest),
        )
    )

    runner = TextTestRunner(verbosity=2)
    runner.run(suite)

    cov.stop()
    cov.save()
开发者ID:silverfernsys,项目名称:sremote,代码行数:50,代码来源:coverage_runner.py

示例12: _bootstrap

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
 def _bootstrap(self):
     """Wrapper around _bootstrap to start coverage."""
     from coverage import Coverage       # avoid circular import
     rcfile = os.environ[COVERAGE_RCFILE_ENV]
     cov = Coverage(data_suffix=True, config_file=rcfile)
     cov.start()
     debug = cov.debug
     try:
         if debug.should("multiproc"):
             debug.write("Calling multiprocessing bootstrap")
         return original_bootstrap(self)
     finally:
         if debug.should("multiproc"):
             debug.write("Finished multiprocessing bootstrap")
         cov.stop()
         cov.save()
         if debug.should("multiproc"):
             debug.write("Saved multiprocessing data")
开发者ID:adriankrupa,项目名称:tk-core,代码行数:20,代码来源:multiproc.py

示例13: _bootstrap

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
 def _bootstrap(self):
     """Wrapper around _bootstrap to start coverage."""
     from coverage import Coverage       # avoid circular import
     cov = Coverage(data_suffix=True)
     cov._warn_preimported_source = False
     cov.start()
     debug = cov._debug
     try:
         if debug.should("multiproc"):
             debug.write("Calling multiprocessing bootstrap")
         return original_bootstrap(self)
     finally:
         if debug.should("multiproc"):
             debug.write("Finished multiprocessing bootstrap")
         cov.stop()
         cov.save()
         if debug.should("multiproc"):
             debug.write("Saved multiprocessing data")
开发者ID:hugovk,项目名称:coveragepy,代码行数:20,代码来源:multiproc.py

示例14: CodeCoverage

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [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)
开发者ID:lettuce,项目名称:radish,代码行数:38,代码来源:codecoverage.py

示例15: Coverage

# 需要导入模块: from coverage import Coverage [as 别名]
# 或者: from coverage.Coverage import save [as 别名]
#!/usr/bin/env python

import os
import sys

from django.core import management


# Point to the correct settings for testing
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings'


if __name__ == "__main__":
    testing = 'test' in sys.argv

    if testing:
        from coverage import Coverage
        cov = Coverage()
        cov.erase()
        cov.start()

    management.execute_from_command_line()

    if testing:
        cov.stop()
        cov.save()
        cov.report()
开发者ID:cdriehuys,项目名称:django_helpcenter,代码行数:29,代码来源:manage.py


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