# eric4.DebugClients.Python.PyCoverage

Module for the collection and analysis of code coverage data.

### Global Attributes

__version__
the_coverage

### Classes

CoverageException |
StatementFindingAstVisitor | A visitor for a parsed Abstract Syntax Tree which finds executable statements.
coverage |

### Functions

analysis |
analysis2 |
annotate |
annotate_file |
begin_recursive |
end_recursive |
erase |
exclude |
report |
start |
stop |
use_cache |

## CoverageException

### Derived from

Exception

### Class Attributes

None

### Methods

None

Up

## StatementFindingAstVisitor

A visitor for a parsed Abstract Syntax Tree which finds executable statements.

### Derived from

compiler.visitor.ASTVisitor

### Class Attributes

default
visitAssert
visitFunction
visitStmt
visitWhile

### Methods

StatementFindingAstVisitor |
doCode |
doElse |
doPlainWordSuite |
doRecursive |
doStatement |
doSuite |
getFirstLine |
getLastLine |
recordAndDispatch |
recordLine |
recordNodeLine |
visitDiscard |
visitFor |
visitGlobal |
visitIf |
visitPass |
visitTryExcept |
visitTryFinally |
visitWith |

#### StatementFindingAstVisitor (Constructor)

StatementFindingAstVisitor(statements, excluded, suite_spots)

#### StatementFindingAstVisitor.doCode

doCode(node)

#### StatementFindingAstVisitor.doElse

doElse(prevsuite, node)

#### StatementFindingAstVisitor.doPlainWordSuite

doPlainWordSuite(prevsuite, suite)

#### StatementFindingAstVisitor.doRecursive

doRecursive(node)

#### StatementFindingAstVisitor.doStatement

doStatement(node)

#### StatementFindingAstVisitor.doSuite

doSuite(intro, body, exclude=0)

#### StatementFindingAstVisitor.getFirstLine

getFirstLine(node)

#### StatementFindingAstVisitor.getLastLine

getLastLine(node)

#### StatementFindingAstVisitor.recordAndDispatch

recordAndDispatch(node)

#### StatementFindingAstVisitor.recordLine

recordLine(lineno)

#### StatementFindingAstVisitor.recordNodeLine

recordNodeLine(node)

#### StatementFindingAstVisitor.visitDiscard

visitDiscard(node)

#### StatementFindingAstVisitor.visitFor

visitFor(node)

#### StatementFindingAstVisitor.visitGlobal

visitGlobal(node)

#### StatementFindingAstVisitor.visitIf

visitIf(node)

#### StatementFindingAstVisitor.visitPass

visitPass(node)

#### StatementFindingAstVisitor.visitTryExcept

visitTryExcept(node)

#### StatementFindingAstVisitor.visitTryFinally

visitTryFinally(node)

#### StatementFindingAstVisitor.visitWith

visitWith(node)
Up

## coverage

### Derived from

None

### Class Attributes

analysis_cache
blank_re
c
cache_default
cache_env
canonical_filename_cache
cexecuted
else_re

### Methods

coverage |
abs_file | Helper function to turn a filename into an absolute normalized filename.
analysis |
analysis2 |
analyze_morf |
annotate |
annotate_file |
begin_recursive |
canonical_filename |
canonicalize_filenames |
collect |
command_line |
end_recursive |
erase |
exclude |
filter_by_prefix | Return list of morfs where the morf name does not begin with any one of the omit_prefixes.
find_docstring_pass_pair |
find_executable_statements |
first_line_of_tree |
fix_frame_filename | Public method used to fixup the filename for a given frame.
format_lines |
getExclude |
get_ready |
get_suite_spots | Analyze a parse tree to find suite introducers which span a number of lines.
get_zip_data | Get data from `filename` if it is a zip file path, or return None if it is not.
help |
is_pass_stmt |
is_string_constant |
last_line_of_tree |
merge_data |
merge_file_data |
morf_filename |
morf_name | Return the name of morf as used in report.
morf_name_compare |
record_multiline |
relative_filename | Convert filename to relative filename from self.relative_dir.
report |
restore |
restore_file |
save |
start |
stop |
stringify |
t |
use_cache |

#### coverage (Constructor)

coverage(basename = None)

#### coverage.abs_file

abs_file(filename)

Helper function to turn a filename into an absolute normalized filename.

#### coverage.analysis

analysis(morf)

#### coverage.analysis2

analysis2(morf)

#### coverage.analyze_morf

analyze_morf(morf)

#### coverage.annotate

annotate(morfs, directory=None, ignore_errors=0, omit_prefixes=[])

#### coverage.annotate_file

annotate_file(filename, statements, excluded, missing, directory=None)

#### coverage.begin_recursive

begin_recursive()

#### coverage.canonical_filename

canonical_filename(filename)

#### coverage.canonicalize_filenames

canonicalize_filenames()

#### coverage.collect

collect()

#### coverage.command_line

command_line(argv, help_fn=None)

#### coverage.end_recursive

end_recursive()

#### coverage.erase

erase()

#### coverage.exclude

exclude(re, reset = 0)

#### coverage.filter_by_prefix

filter_by_prefix(morfs, omit_prefixes)

Return list of morfs where the morf name does not begin with any one of the omit_prefixes.

#### coverage.find_docstring_pass_pair

find_docstring_pass_pair(tree, spots)

#### coverage.find_executable_statements

find_executable_statements(text, exclude=None)

#### coverage.first_line_of_tree

first_line_of_tree(tree)

#### coverage.fix_frame_filename

fix_frame_filename(frame)

Public method used to fixup the filename for a given frame.

The logic employed here is that if a module was loaded from a .pyc file, then the correct .py to operate with should be in the same path as the .pyc. The reason this logic is needed is that when a .pyc file is generated, the filename embedded and thus what is readable in the code object of the frame object is the fully qualified filepath when the pyc is generated. If files are moved from machine to machine this can break debugging as the .pyc will refer to the .py on the original machine. Another case might be sharing code over a network... This logic deals with that.

frame
  the frame object

#### coverage.format_lines

format_lines(statements, lines)

#### coverage.getExclude

getExclude()

#### coverage.get_ready

get_ready(parallel_mode=False)

#### coverage.get_suite_spots

get_suite_spots(tree, spots)

Analyze a parse tree to find suite introducers which span a number of lines.

#### coverage.get_zip_data

get_zip_data(filename)

Get data from `filename` if it is a zip file path, or return None if it is not.

#### coverage.help

help(error=None)

#### coverage.is_pass_stmt

is_pass_stmt(tree)

#### coverage.is_string_constant

is_string_constant(tree)

#### coverage.last_line_of_tree

last_line_of_tree(tree)

#### coverage.merge_data

merge_data(new_data)

#### coverage.merge_file_data

merge_file_data(cache_data, new_data)

#### coverage.morf_filename

morf_filename(morf)

#### coverage.morf_name

morf_name(morf)

Return the name of morf as used in report.

#### coverage.morf_name_compare

morf_name_compare(x, y)

#### coverage.record_multiline

record_multiline(spots, i, j)

#### coverage.relative_filename

relative_filename(filename)

Convert filename to relative filename from self.relative_dir.

#### coverage.report

report(morfs, show_missing=1, ignore_errors=0, file=None, omit_prefixes=[])

#### coverage.restore

restore()

#### coverage.restore_file

restore_file(file_name)

#### coverage.save

save()

#### coverage.start

start(parallel_mode=False)

#### coverage.stop

stop()

#### coverage.stringify

stringify()

#### coverage.t

t(f, w, unused)

#### coverage.use_cache

use_cache(usecache, cache_file=None)
Up

## analysis

analysis(*args, **kw)
Up

## analysis2

analysis2(*args, **kw)
Up

## annotate

annotate(*args, **kw)
Up

## annotate_file

annotate_file(*args, **kw)
Up

## begin_recursive

begin_recursive(*args, **kw)
Up

## end_recursive

end_recursive(*args, **kw)
Up

## erase

erase(*args, **kw)
Up

## exclude

exclude(*args, **kw)
Up

## report

report(*args, **kw)
Up

## start

start(*args, **kw)
Up

## stop

stop(*args, **kw)
Up

## use_cache

use_cache(*args, **kw)
Up