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


Python coverage.Coverage类代码示例

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


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

示例1: run

    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)
开发者ID:,项目名称:,代码行数:33,代码来源:

示例2: run_tests

    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,代码行数:34,代码来源:support.py

示例3: CoverageContext

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,代码行数:11,代码来源:run.py

示例4: run

    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,代码行数:11,代码来源:setup.py

示例5: run_tests

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,代码行数:33,代码来源:utils.py

示例6: run_tests

    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,代码行数:32,代码来源:setup.py

示例7: __init__

    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)
开发者ID:lettuce,项目名称:radish,代码行数:9,代码来源:codecoverage.py

示例8: main

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)
开发者ID:hamishcoleman,项目名称:python-simpleproject,代码行数:43,代码来源:run_tests.py

示例9: _bootstrap

 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,代码行数:9,代码来源:monkey.py

示例10: _bootstrap

 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,代码行数:13,代码来源:coverage_utils.py

示例11: _bootstrap

 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,代码行数:10,代码来源:monkey.py

示例12: run_with_coverage

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,代码行数:10,代码来源:run.py

示例13: test_to_file_and_from_file

def test_to_file_and_from_file():

    cov = Coverage()
    cov['foo'].extend(range(1, 11))
    cov['bar'].extend(range(1, 3))
    cov['baz']

    temp_write_fh = NamedTemporaryFile()
    cov.to_file(temp_write_fh.file)
    temp_write_fh.file.flush()

    temp_read_fh = open(temp_write_fh.name)
    loaded = Coverage()
    loaded.from_file(temp_read_fh)

    x = array('L')
    x.extend(range(1, 11))

    eq_(loaded['foo'], x)

    x = array('L')
    x.extend(range(1, 3))

    eq_(loaded['bar'], x)

    x = array('L')

    eq_(loaded['baz'], x)
开发者ID:abuchanan,项目名称:coverage,代码行数:28,代码来源:tests.py

示例14: run_coverage

    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,代码行数:7,代码来源:codemon.py

示例15: _bootstrap

 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,代码行数:11,代码来源:multiproc.py


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