Comments (5)
Help me understand your situation. In this code:
a = my_function1()
if debug:
msg = "blah blah"
# no cover: start
log_message(msg, a)
b = my_function2()
# no cover: stop
How would the msg =
line be executed, but the log_message()
line would not? Why do we need to exclude a block of lines adjacent to other executed lines?
from coveragepy.
Maybe in cases like:
a = my_function1()
if debug:
msg = "blah blah"
if a is None: # common path
return my_function3()
# no cover: start
log_message(msg, a)
b = my_function2()
return b # no cover: stop
Or even:
def main():
if not DEBUG:
sys.exit()
if __name__ == "__main__":
main()
from debug import show_info # no cover: start
show_info() # no cover: stop
So it may make sense after some way of exiting the normal flow of execution.
This means the end marker wouldn't be strictly necessary if the exclusion ended automatically on block end. But it might be useful to, e.g., temporarily mark a couple of blocks for exclusion.
from coveragepy.
You can do this like this:
if True: # pragma: no cover
a()
b()
c()
from coveragepy.
As of commit 1fe897d, you can do this with a multi-line exclusion regex:
[report]
exclude_also =
# no cover: start(?s:.)*?# no cover: stop
from coveragepy.
This is now released as part of coverage 7.6.0.
from coveragepy.
Related Issues (20)
- Nested matches of exclude_lines patterns leads to unmatched lines being excluded HOT 3
- Add a hint that `coverage combine` might be needed
- Allow disabling parallel mode from the command line HOT 3
- BUG: inconsistent meaning of `skip_covered` between `coverage report` and `coverage html`
- MemoryError in `coverage report` on Python 3.12 HOT 5
- Zero coverage of process spawned by dogtail HOT 4
- oss-fuzz 69058: TokenError HOT 4
- Support coverage plugins with sys.monitoring
- Memory leak when generating reports HOT 18
- Line incorrectly reported as uncovered in python 3.11 involving `asyncio.to_thread` and a conditional
- A way to get report data in detail HOT 15
- `continue` incorrectly marked as uncovered on python 3.9 HOT 2
- pragma: no cover ignored and coverage wrongly calculated HOT 4
- How to exclude a line without the block it introduces? HOT 1
- coverage.tracer thread-safety warning with Python 3.13 free-threaded HOT 3
- PermissionError: [Errno 13] Permission denied: '/dev/stdout' HOT 2
- how to write a parser for raw coverage file (.coverage) and a json reporter in golang ? HOT 2
- COVERAGE_CORE=sysmon with branch coverage can be 2x slower than default in some cases HOT 1
- Overall Branch and Function coverage percentage in json report HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coveragepy.