Skip to content

API: Measure a single function #531

Open
@nedbat

Description

@nedbat

Originally reported by space one (Bitbucket: spaceone, GitHub: spaceone)


It would be nice if the docs contain a single code snipped for how to measure a single function. Might this be possible?

from coverage import Coverage
def my_target_function():
   return True
cov = Coverage()
cov.measure(my_target_function)
my_target_function()
cov.stop()
cov.report()

measure should be able to handle functions/classes/modules. I'm okay to give as second parameter the source-code-file (but I guess the function internally has a reference to it anywhere). (I think the source-code file is also only needed for the HTML report?!).


Metadata

Metadata

Assignees

No one assigned

    Labels

    apiChanges to the public APIenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions