question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Increase Python code coverage

See original GitHub issue

There 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.hooks 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:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ktbarrettcommented, Jul 22, 2021

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 from xunit_reporter.py: #2200 Removed dead code from utils: #2228.

0reactions
cmarqucommented, Sep 29, 2020

The C++ coverage setup is now tracked in #2088.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found