How to use the covimerage.logger.logger.warning function in covimerage

To help you get started, we’ve selected a few covimerage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Vimjas / covimerage / covimerage / __init__.py View on Github external
if m:
            funcname = 's:' + funcname[m.end():]

        found = []
        for script in self.scripts:
            try:
                lnums = script.func_to_lnums[funcname]
            except KeyError:
                continue

            for script_lnum in lnums:
                if self.source_contains_func(script, script_lnum, func):
                    found.append((script, script_lnum))
        if found:
            if len(found) > 1:
                logger.warning('Found multiple sources for function %s (%s).',
                               func, (', '.join('%s:%d' % (f[0].path, f[1])
                                                for f in found)))
            return found[0]
        return None
github Vimjas / covimerage / covimerage / __init__.py View on Github external
m = RE_CONTINUING_LINE.match(next_line)
                    if m:
                        script_line += next_line[m.end():]
                        continue
                    func_lnum += 1
                    if script_line != func.lines[func_lnum].line:
                        script_is_func = False
                        break
                    script_line = s.lines[script_lnum].line

                if script_is_func:
                    found.append((s, lnum))

        if found:
            if len(found) > 1:
                logger.warning(
                    'Found multiple sources for anonymous function %s (%s).',
                    func.name, (', '.join('%s:%d' % (f[0].path, f[1])
                                          for f in found)))

            for s, lnum in found:
                if lnum in s.mapped_dict_functions:
                    # More likely to happen with merged profiles.
                    logger.debug(
                        'Found already mapped dict function again (%s:%d).',
                        s.path, lnum)
                    continue
                s.mapped_dict_functions.add(lnum)
                return (s, lnum)
            return found[0]
github Vimjas / covimerage / covimerage / __init__.py View on Github external
def write_coveragepy_data(self, data_file='.coverage'):
        import coverage

        cov_data = self.get_coveragepy_data()
        try:
            line_counts = cov_data.line_counts()
        except AttributeError:
            line_counts = coverage.data.line_counts(cov_data)
        if not line_counts:
            logger.warning('Not writing coverage file: no data to report!')
            return False

        if isinstance(data_file, string_types):
            logger.info('Writing coverage file %s.', data_file)
            try:
                write_file = cov_data.write_file
            except AttributeError:
                # coveragepy 5
                write_file = cov_data._write_file
            write_file(data_file)
        else:
            try:
                filename = data_file.name
            except AttributeError:
                filename = str(data_file)
            logger.info('Writing coverage file %s.', filename)