Many thanks for taking into consideration my question, for creating this great package and sorry for my bad explanations.
My real concern is how can I know what proportion of code that I really use is tested.
I thought I could do that by running coverage.py on my “used-in-production” code with a context “used-in-production”, then run coverage.py on my tests with a context “tested” and finally combine the results for use by coverage htmlcov
Reading at the documentation of coverage htmlcov, I misinterpreted the word “display” in
--contexts=REGEX1,REGEX2,...
Only display data from lines covered in the given
contexts. Accepts Python regexes, which must be
quoted.
as “redefine statements lines as statement lines in the given context” in the htmlcov whereas form my later understanding it meant “redefine covered lines as covered lines in the given context”
I hoped I could get either of the following behaviour:
- Only lines from
used-in-production_context are shown in the htmlcov
- Lines not in
used-in-production_context are counted as excluded in the htmlcov
Here is an example for a file.py:
def used_in_production_but_untested():
return
def used_in_production_and_tested():
return
def unused_in_production_and_untested():
return
def unused_in_production_and_tested():
return
Desired behaviour 1, in htmlcov:
def used_in_production_but_untested():
return # missed
def used_in_production_and_tested():
return # covered
Desired behaviour 2, in htmlcov:
def used_in_production_but_untested():
return # missed
def used_in_production_and_tested():
return # covered
def unused_in_production_and_untested(): # excluded
return # excluded
def unused_in_production_and_tested(): # excluded
return # excluded
I hope this is clearer like this
Thank you