-
-
Notifications
You must be signed in to change notification settings - Fork 456
Description
Excluding a code block
Having a greater code block it would be great to have aq change to disable a code block from coverage with a start
end end
token. Currently only a single line can be excluded or code blocks within a clause. For example either the whole debug clause can be excluded but not the last two statements
This excludes the the whole if debug
clause
a = my_function1()
if debug: # pragma: no cover
msg = "blah blah"
log_message(msg, a)
b = my_function2()
but I want to exclude the latest two statements (in practice these can be a lot of statemens). This can be done by excluding every line like
a = my_function1()
if debug:
msg = "blah blah"
log_message(msg, a) # pragma: no cover
b = my_function2() # pragma: no cover
but this may lead to a lot of such pragma: no cover
command or a senseless clause must be used like
a = my_function1()
if debug:
msg = "blah blah"
if True: # pragma: no cover
log_message(msg, a)
b = my_function2()
start/end command as proposal
A start/end command can be introduced to solve this issue like pragma: no cover start
and pragma: no cover stop
or shorter no cover: start
and no cover: stop
or something like that. Instead of no cover: stop
command a no cover: end
command can be implemented as stop command. The code can then be excluded with
a = my_function1()
if debug:
msg = "blah blah"
# no cover: start
log_message(msg, a)
b = my_function2()
# no cover: stop
Other implementations as a sample
Coverage for Dart language support such block exclusion: (https://github.com/dart-lang/coverage)