Increase Python code coverage
See original GitHub issueThere are a few reasons why coverage is low; the reasons vary. This issue exists to list and track the completion of tasks relating to increasing code coverage. I think the next realistic goal is to take coverage above 80%. In general, we need to mark error cases we cannot trigger on our own with pragma: no cover
.
Dead Code
Coverage is 0% on dead code… Some code is “public” and must go through a deprecation cycle, but the rest can be removed.
- xunit_reporter.py
- update_testsuite
- update_testsuites
- add_log
- add_failure
- The entire
File
class
- utils.py
- reject_remaining_kwargs
- get_python_integer_types
- main script part
Untested, potential code baggage
This stuff isn’t tested, likely because it’s not a very useful feature and/or undocumented.
- utils.py
- pack
- unpack, and the associated code in handle.py
Untested
- memdebug.py and MEM_CHECK=1 is never tested in CI.
- scheduler.py
- COCOTB_SCHEDULER_DEBUG=1 is never run in CI, so a lot of statements are missed
- COCOTB_ENABLE_PROFILING=1 is never run in CI, so a lot of statements are missed
- regression.py
- COVERAGE=1 is never run in CI, so a lot of statements are missed
- actually failing tests are untested.
- handle.py
- just a lot of stuff, it has a pretty large interface and most of it isn’t useful, so it isn’t tested
- binary.py
- All of the logic and arithmetic functionality are untested
- in general
bigEndian=True
isn’t well tested
-
cocotb.hook
s are untested. This affects scheduler.py and decorators.py - Testbenching components are all low.
- scoreboard has some untested features
- bus
-
drive
,capture
,sample
, and<=
are unused on the base classe
-
- drivers
- OBP is untested
- XGMIII is untested
- AXI4Slave is untested
- optional signals and some features in AvalonDriver are untested
- monitors
- XGMII is untested
- generators
- packet.py is untested
Other
__init__.py
-
initialize_testbench
isn’t covered. This could be because the coverage is started in this function, there is likely some way around this.
-
- config.py is untested. It isn’t meant to be used in the Python environment by the user. This file should probably not be in the cocotb package.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How can I improve code coverage of Python3 - Stack Overflow
1. You no longer need to write these TestSuite stanzas. Just use "python -m unittest discover" · Then you wouldn't be able to...
Read more >Improve Code Quality Using Test Coverage - CODE Magazine
In this article, I'll introduce the concept of code coverage by exploring the value of measurements such as statement coverage, function ...
Read more >Increase Test Coverage - Python Developer's Guide
A good, easy way to become acquainted with Python's code and to help out is to help increase the test coverage for Python's...
Read more >Coverage.py — Coverage.py 7.0.0 documentation
Coverage.py is a tool for measuring code coverage of Python programs. It monitors your program, noting which parts of the code have been...
Read more >Python test coverage - SonarQube Documentation
Add coverage to your build process · Tox, to configure the tests · Pytest, to execute the tests · Coverage, (the Coverage.py tool,)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hooks were removed: #2508 The testbenching components were removed: #2289
_initialize_testbench
is now covered as well as it can be: #2400 removed dead code fromxunit_reporter.py
: #2200 Removed dead code from utils: #2228.The C++ coverage setup is now tracked in #2088.