(self, path, lines, lnotab, lines_hit, encoding=None)
return n_hits, n_lines
Return a coverage results file in path.
Return a coverage results file in path.
Return a coverage results file in path .
def write_results_file(self, path, lines, lnotab, lines_hit, encoding=None):
        """Return a coverage results file in path."""
        # ``lnotab`` is a dict of executable lines, or a line number "table"

        try:
            outfile = open(path, "w", encoding=encoding)
        except OSError as err:
            print(("trace: Could not open %r for writing: %s "
                                  "- skipping" % (path, err)), file=sys.stderr)
            return 0, 0

        n_lines = 0
        n_hits = 0
        with outfile:
            for lineno, line in enumerate(lines, 1):
                # do the blank/comment match to try to mark more lines
                # (help the reader find stuff that hasn't been covered)
                if lineno in lines_hit:
                    outfile.write("%5d: " % lines_hit[lineno])
                    n_hits += 1
                    n_lines += 1
                elif lineno in lnotab and not PRAGMA_NOCOVER in line:
                    # Highlight never-executed lines, unless the line contains
                    # #pragma: NO COVER
                    outfile.write(">>>>>> ")
                    n_lines += 1
                else:
                    outfile.write("       ")
                outfile.write(line.expandtabs(8))

        return n_hits, n_lines
def write_results_file ( self , path , lines , lnotab , lines_hit , encoding = None ) : # ``lnotab`` is a dict of executable lines, or a line number "table" try : outfile = open ( path , "w" , encoding = encoding ) except OSError as err : print ( ( "trace: Could not open %r for writing: %s " "- skipping" % ( path , err ) ) , file = sys . stderr ) return 0 , 0 n_lines = 0 n_hits = 0 with outfile : for lineno , line in enumerate ( lines , 1 ) : # do the blank/comment match to try to mark more lines # (help the reader find stuff that hasn't been covered) if lineno in lines_hit : outfile . write ( "%5d: " % lines_hit [ lineno ] ) n_hits += 1 n_lines += 1 elif lineno in lnotab and not PRAGMA_NOCOVER in line : # Highlight never-executed lines, unless the line contains # #pragma: NO COVER outfile . write ( ">>>>>> " ) n_lines += 1 else : outfile . write ( "       " ) outfile . write ( line . expandtabs ( 8 ) ) return n_hits , n_lines