Пример #1
0
    def __init__(self, test_labels, options):
        super(Task, self).__init__(test_labels, options)
        self.test_apps = get_apps_under_test(test_labels, options["test_all"])
        self.output_dir = options["output_dir"]
        self.with_migrations = options.get(
            "coverage_with_migrations", getattr(settings, "COVERAGE_WITH_MIGRATIONS", False)
        )

        self.html_dir = options.get("coverage_html_report_dir") or getattr(
            settings, "COVERAGE_REPORT_HTML_OUTPUT_DIR", ""
        )

        self.branch = options.get("coverage_measure_branch", getattr(settings, "COVERAGE_MEASURE_BRANCH", True))

        self.exclude_locations = []
        modnames = options.get("coverage_excludes") or getattr(settings, "COVERAGE_EXCLUDES", [])
        for modname in modnames:
            try:
                self.exclude_locations.append(os.path.dirname(import_module(modname).__file__))
            except ImportError:
                pass

        # Extra folders to exclude. Particularly useful to specify things like
        # apps/company/migrations/*
        self.exclude_locations.extend(getattr(settings, "COVERAGE_EXCLUDES_FOLDERS", []))
        # import ipdb; ipdb.set_trace()

        self.coverage = coverage(
            branch=self.branch,
            source=self.test_apps,
            omit=self.exclude_locations,
            config_file=options.get("coverage_rcfile") or Task.default_config_path(),
        )
Пример #2
0
def run_server(port, server_ready, done):
    from coverage.collector import Collector
    from coverage.control import coverage
    if Collector._collectors:
        cov = coverage(data_suffix=True)
        cov.start()
        def stop_cov(*args):
            cov.stop()
            cov.save()
            raise SystemExit('killed')
    else:
        def stop_cov(*args):
            raise SystemExit('killed')

    fp = open('/tmp/null', 'a+')
    os.dup2(fp.fileno(), 0)
    os.dup2(fp.fileno(), 1)
    os.dup2(fp.fileno(), 2)

    os.environ['REMOTE_USER'] = '******'
    from wsgiref.simple_server import make_server
    s = make_server('localhost', port, basicdb.app)

    signal.signal(signal.SIGINT, stop_cov)
    server_ready.set()
    s.serve_forever()
Пример #3
0
 def results(self):
     cov = coverage(
         data_file=self._data_file, config_file=self._config_file)
     cov.load()
     reporter = Reporter(cov, cov.config)
     reporter.find_code_units(None)
     return self.results_for_reporter(reporter)
Пример #4
0
def run_server(port, server_ready, done):
    from coverage.collector import Collector
    from coverage.control import coverage
    if Collector._collectors:
        cov = coverage(data_suffix=True)
        cov.start()

        def stop_cov(*args):
            cov.stop()
            cov.save()
            raise SystemExit('killed')
    else:

        def stop_cov(*args):
            raise SystemExit('killed')

    fp = open('/tmp/null', 'a+')
    os.dup2(fp.fileno(), 0)
    os.dup2(fp.fileno(), 1)
    os.dup2(fp.fileno(), 2)

    os.environ['REMOTE_USER'] = '******'
    from wsgiref.simple_server import make_server
    s = make_server('localhost', port, basicdb.app)

    signal.signal(signal.SIGINT, stop_cov)
    server_ready.set()
    s.serve_forever()
Пример #5
0
 def _bootstrap(self):
     cov = coverage(data_suffix=True)
     cov.start()
     try:
         return original(self)
     finally:
         cov.stop()
         cov.save()
Пример #6
0
 def _bootstrap(self):
     cov = coverage(data_suffix=True)
     cov.start()
     try:
         return original(self)
     finally:
         cov.stop()
         cov.save()
Пример #7
0
 def _bootstrap(self):
     cov = coverage(data_suffix=True)
     cov.start()
     cov._warn_no_data = False
     cov._warn_unimported_source = False
     try:
         return process_cls._bootstrap(self)
     finally:
         cov.stop()
         cov.save()
Пример #8
0
 def _bootstrap(self):
     cov = coverage(data_suffix=True)
     cov.start()
     cov._warn_no_data = False
     cov._warn_unimported_source = False
     try:
         return process_cls._bootstrap(self)
     finally:
         cov.stop()
         cov.save()
Пример #9
0
 def __init__(self, test_labels, options):
     super(Task, self).__init__(test_labels, options)
     self.test_apps = get_apps_under_test(test_labels, options['test_all'])
     self.output_dir = options['output_dir']
     self.excludes = options['coverage_excludes']
     self.html_dir = options['coverage_html_report_dir']
     
     self.coverage = coverage(branch = options['coverage_measure_branch'],
                              source = test_labels or None,
                              config_file = options.get('coverage_rcfile', Task.default_config_path))
Пример #10
0
    def __init__(self, test_labels, options):
        super(Task, self).__init__(test_labels, options)
        self.test_apps = get_apps_under_test(test_labels, options['test_all'])
        self.output_dir = options['output_dir']
        self.excludes = options['coverage_excludes']
        self.html_dir = options['coverage_html_report_dir']

        self.coverage = coverage(branch=options['coverage_measure_branch'],
                                 source=test_labels or None,
                                 config_file=options['coverage_rcfile']
                                 or Task.default_config_path())
Пример #11
0
    def __init__(self, test_labels, options):
        super(Task, self).__init__(test_labels, options)
        self.test_apps = get_apps_under_test(test_labels, options["test_all"])
        self.output_dir = options["output_dir"]
        self.excludes = options["coverage_excludes"]
        self.html_dir = options["coverage_html_report_dir"]

        self.coverage = coverage(
            branch=options["coverage_measure_branch"],
            source=test_labels or None,
            config_file=options["coverage_rcfile"] or Task.default_config_path(),
        )
Пример #12
0
 def __init__(self, verbosity=1, interactive=True, failfast=True, **kwargs):
     super(TestSuiteRunner, self).__init__(verbosity, interactive, failfast, **kwargs)
     if getattr(settings, 'TEST_WITH_COVERAGE', False):
         omit_list = [
             '%s/lib/*' % os.environ['VIRTUAL_ENV'],  # libraries
             '%s/src/*' % os.environ['VIRTUAL_ENV'],  # source libraries
             '*/tests*',  # all tests
             'config/*',  # all configs
         ]
         self.coverage = coverage(branch=True, omit=omit_list)
         self.coverage_format = getattr(settings, 'TEST_COVERAGE_FORMAT', 'xml')
     else:
         self.coverage = None
    def __init__(self, **options):
        self.output_dir = options['output_dir']
        self.with_migrations = options['coverage_with_migrations']
        self.html_dir = options['coverage_html_report_dir']
        self.branch = options['coverage_measure_branch']

        self.exclude_locations = options['coverage_excludes'] or None

        self.coverage = coverage(
            branch=self.branch,
            source=settings.PROJECT_APPS,
            omit=self.exclude_locations,
            config_file=options.get('coverage_rcfile') or default_config_path()
        )
Пример #14
0
    def __init__(self):
        try:
            from coverage.control import coverage
        except ImportError:
            raise ImportError('coverage is not installed')
        else:
            coverage_config_file = None
            for argv in sys.argv:
                if argv.startswith('--coverage-rcfile='):
                    _, coverage_config_file = argv.split('=')

            self.coverage = coverage(
                branch=True,
                config_file=coverage_config_file or default_coverage_config())
            self.coverage.start()
Пример #15
0
    def __init__(self, test_labels, options):
        super(Task, self).__init__(test_labels, options)
        self.test_apps = get_apps_under_test(test_labels, options['test_all'])
        self.output_dir = options['output_dir']
        self.html_dir = options['coverage_html_report_dir']

        self.exclude_locations = []
        for modname in options['coverage_excludes']:
            try:
                self.exclude_locations.append(os.path.dirname(import_module(modname).__file__))
            except ImportError:
                pass

        self.coverage = coverage(branch=options['coverage_measure_branch'],
                                 source=self.test_apps,
                                 config_file=options['coverage_rcfile'] or Task.default_config_path())
Пример #16
0
    def __init__(self, test_labels, options):
        super(Task, self).__init__(test_labels, options)
        self.test_apps = get_apps_under_test(test_labels, options['test_all'])
        self.output_dir = options['output_dir']
        self.html_dir = options['coverage_html_report_dir']

        self.exclude_locations = []
        for modname in options['coverage_excludes']:
            try:
                self.exclude_locations.append(
                    os.path.dirname(import_module(modname).__file__))
            except ImportError:
                pass

        self.coverage = coverage(branch=options['coverage_measure_branch'],
                                 source=self.test_apps,
                                 config_file=options['coverage_rcfile']
                                 or Task.default_config_path())
Пример #17
0
    def __init__(self, test_labels, options):
        super(Task, self).__init__(test_labels, options)
        self.test_apps = get_apps_under_test(test_labels, options['test_all'])
        self.output_dir = options['output_dir']
        self.with_migrations = options.get('coverage_with_migrations',
                                    getattr(settings,
                                            'COVERAGE_WITH_MIGRATIONS', False))

        self.html_dir = options.get('coverage_html_report_dir') or \
                            getattr(settings,
                                    'COVERAGE_REPORT_HTML_OUTPUT_DIR', '')

        self.branch = options.get('coverage_measure_branch',
                                  getattr(settings,
                                          'COVERAGE_MEASURE_BRANCH', True))

        self.exclude_locations = []
        modnames = options.get('coverage_excludes') or \
                        getattr(settings, 'COVERAGE_EXCLUDES', [])
        for modname in modnames:
            try:
                self.exclude_locations.append(
                        os.path.dirname(
                            import_module(modname).__file__
                        )
                )
            except ImportError:
                pass

        # Extra folders to exclude. Particularly useful to specify things like
        # apps/company/migrations/*
        self.exclude_locations.extend(
                        getattr(settings, 'COVERAGE_EXCLUDES_FOLDERS', []))

        omit = self.exclude_locations
        if not omit:
            omit = None

        self.coverage = coverage(branch=self.branch,
                                 source=self.test_apps,
                                 omit=omit,
                                 config_file=options.get('coverage_rcfile') or
                                                 Task.default_config_path())
Пример #18
0
    def __init__(self, test_labels, options):
        super(Task, self).__init__(test_labels, options)
        self.test_apps = get_apps_under_test(test_labels, options['test_all'])
        self.output_dir = options['output_dir']
        self.with_migrations = options.get(
            'coverage_with_migrations',
            getattr(settings, 'COVERAGE_WITH_MIGRATIONS', False))

        self.html_dir = options.get('coverage_html_report_dir') or \
                            getattr(settings,
                                    'COVERAGE_REPORT_HTML_OUTPUT_DIR', '')

        self.branch = options.get(
            'coverage_measure_branch',
            getattr(settings, 'COVERAGE_MEASURE_BRANCH', True))

        self.exclude_locations = []
        modnames = options.get('coverage_excludes') or \
                        getattr(settings, 'COVERAGE_EXCLUDES', [])
        for modname in modnames:
            try:
                self.exclude_locations.append(
                    os.path.dirname(import_module(modname).__file__))
            except ImportError:
                pass

        # Extra folders to exclude. Particularly useful to specify things like
        # apps/company/migrations/*
        self.exclude_locations.extend(
            getattr(settings, 'COVERAGE_EXCLUDES_FOLDERS', []))

        omit = self.exclude_locations
        if not omit:
            omit = None

        self.coverage = coverage(branch=self.branch,
                                 source=self.test_apps,
                                 omit=omit,
                                 config_file=options.get('coverage_rcfile')
                                 or Task.default_config_path())
Пример #19
0
    def __init__(self, test_labels, options):
        super(Task, self).__init__(test_labels, options)
        self.test_apps = get_apps_under_test(test_labels, options['test_all'])
        self.output_dir = options['output_dir']
        self.with_migrations = options.get('coverage_with_migrations',
                                           getattr(settings, 'COVERAGE_WITH_MIGRATIONS', False))
        self.html_dir = options.get('coverage_html_report_dir',
                                    getattr(settings, 'COVERAGE_REPORT_HTML_OUTPUT_DIR', ''))
        self.branch = options.get('coverage_measure_branch',
                                  getattr(settings, 'COVERAGE_MEASURE_BRANCH', True))

        self.exclude_locations = []
        for modname in options.get('coverage_excludes',
                                   getattr(settings, 'COVERAGE_EXCLUDES', [])):
            try:
                self.exclude_locations.append(os.path.dirname(import_module(modname).__file__))
            except ImportError:
                pass

        self.coverage = coverage(branch=self.branch,
                                 source=self.test_apps,
                                 config_file=options.get('coverage_rcfile') or Task.default_config_path())
    def __init__(self, **options):
        self.output_dir = options['output_dir']
        self.with_migrations = options['coverage_with_migrations']
        self.html_dir = options['coverage_html_report_dir']
        self.branch = options['coverage_measure_branch']

        self.exclude_locations = []
        modnames = options['coverage_excludes']
        for modname in modnames:
            try:
                self.exclude_locations.append(
                    os.path.dirname(import_module(modname).__file__))
            except ImportError:
                pass

        # Extra folders to exclude. Particularly useful to specify things like
        # apps/company/migrations/*
        self.exclude_locations.extend(settings.COVERAGE_EXCLUDES_FOLDERS)

        self.coverage = coverage(branch=self.branch,
                                 source=settings.PROJECT_APPS,
                                 omit=self.exclude_locations,
                                 config_file=options.get('coverage_rcfile')
                                 or default_config_path())
Пример #21
0
 def wrapper(*args, **kwargs):
     """Singleton wrapper around a coverage method."""
     global _the_coverage
     if not _the_coverage:
         _the_coverage = coverage(auto_data=True)
     return getattr(_the_coverage, name)(*args, **kwargs)
Пример #22
0
 def wrapper(*args, **kwargs):
     global _the_coverage
     if not _the_coverage:
         _the_coverage = coverage(auto_data=True)
     return getattr(_the_coverage, name)(*args, **kwargs)
Пример #23
0
 def wrapper(*args, **kwargs):
     global _the_coverage
     if not _the_coverage:
         _the_coverage = coverage(auto_data=True)
     return getattr(_the_coverage, name)(*args, **kwargs)
Пример #24
0
 def wrapper(*args, **kwargs):
     """Singleton wrapper around a coverage method."""
     global _the_coverage
     if not _the_coverage:
         _the_coverage = coverage(auto_data=True)
     return getattr(_the_coverage, name)(*args, **kwargs)