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


Python Coverage.start方法代碼示例

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


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

示例1: run_coverage

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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: run_tests

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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: run_tests

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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

示例4: run_tests

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [as 別名]
    def run_tests(self):
        from illume import config
        from coverage import Coverage

        config.setenv("test")

        from pytest import main
        from illume.util import remove_or_ignore_dir
        from logging import basicConfig, DEBUG

        basicConfig(level=DEBUG, filename="illume-test.log")

        project_root = config.get("PROJECT_ROOT")
        data_dir = config.get("DATA_DIR")
        cov_config_dir = os.path.join(project_root, '.coveagerc')

        cov = Coverage(config_file=cov_config_dir)
        # Remvoe data directory in case tests failed to complete last time.
        remove_or_ignore_dir(data_dir)
        cov.start()

        exit_code = main(shlex.split(self.pytest_args or ""))

        cov.stop()
        cov.xml_report()

        # Remove data directory if tests passed successfully. Keep it around
        # if tests failed so the developer can troubleshoot the problem.
        if exit_code == 0:
            remove_or_ignore_dir(data_dir)

        sys.exit(exit_code)
開發者ID:iakinsey,項目名稱:illume,代碼行數:34,代碼來源:setup.py

示例5: _bootstrap

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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

示例6: run_with_coverage

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [as 別名]
def run_with_coverage(run):
    from coverage import Coverage
    coverage = Coverage()
    coverage.start()

    apply(run)

    coverage.end()

    coverage.result(['../core/%s' % prefix,])
開發者ID:jtauber,項目名稱:redfoot-orig,代碼行數:12,代碼來源:run.py

示例7: _bootstrap

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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

示例8: _bootstrap

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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

示例9: _bootstrap

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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

示例10: CoverageContext

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [as 別名]
class CoverageContext(object):
    def __init__(self):
        from coverage import Coverage
        self._cov = Coverage(cover_pylib=False)
        self._cov.start()

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self._cov.stop()
開發者ID:LukaszStem,項目名稱:azure-cli,代碼行數:13,代碼來源:run.py

示例11: run

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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()
開發者ID:mcrute,項目名稱:pydora,代碼行數:13,代碼來源:setup.py

示例12: run

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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

示例13: _bootstrap

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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

示例14: run_test_suite

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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

示例15: with_coverage

# 需要導入模塊: from coverage import Coverage [as 別名]
# 或者: from coverage.Coverage import start [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


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