Skip to content

Coverage improvement plan#1147

Merged
benoit-cty merged 5 commits intomlco2:masterfrom
DiogoRibeiro7:coverage-improvement-plan
Mar 30, 2026
Merged

Coverage improvement plan#1147
benoit-cty merged 5 commits intomlco2:masterfrom
DiogoRibeiro7:coverage-improvement-plan

Conversation

@DiogoRibeiro7
Copy link
Copy Markdown
Contributor

Description

This PR increases package test coverage and stabilizes a couple of failing tests in the non-integration suite.

Changes included:

  • added coverage for codecarbon.cli.auth
  • added coverage for codecarbon.cli.cli_utils
  • added coverage for codecarbon.cli.monitor
  • expanded coverage for codecarbon.core.api_client
  • expanded coverage for codecarbon.core.cpu
  • expanded coverage for codecarbon.core.powermetrics
  • expanded coverage for codecarbon.core.resource_tracker
  • expanded coverage for codecarbon.external.ram
  • stabilized tests/test_core_util.py for Windows tempfile behavior
  • stabilized tests/test_unsupported_gpu.py to avoid exact-zero assertions on noisy unsupported-GPU measurements

This raised package coverage to 85% and restored a green non-integration test run.

Related Issue

N/A

Motivation and Context

The package had several low-coverage modules in CLI, API, hardware-detection, and resource-tracking paths, and the non-integration suite still had a couple of unstable failures on Windows/runtime-dependent paths.

This change improves confidence in those branches, makes the suite more deterministic across environments, and gives a cleaner baseline for future work.

How Has This Been Tested?

Tested with targeted pytest runs while adding each batch of tests, then with a full package coverage run.

Commands used:

  • uv run --group dev pytest tests\cli\test_cli_utils.py -q
  • uv run --group dev pytest tests\cli\test_monitor.py -q
  • uv run --group dev pytest tests\cli\test_cli_auth.py -q
  • uv run --group dev pytest tests\test_api_call.py -q
  • uv run --group dev pytest tests\test_resource_tracker.py tests\test_powermetrics.py -q
  • uv run --group dev pytest tests\test_cpu.py -q
  • uv run --group dev pytest tests\test_ram.py -q
  • uv run --group dev pytest tests\test_core_util.py -q
  • uv run --group dev pytest tests\test_unsupported_gpu.py -q
  • uv run --group dev pytest --cov --cov-report=term --cov-report=xml --ignore=tests/test_viz_data.py -q -m "not integ_test" tests/

Final result:

  • 456 passed, 19 skipped, 3 deselected

Screenshots (if appropriate):

N/A

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING.md document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@DiogoRibeiro7 DiogoRibeiro7 requested a review from a team as a code owner March 27, 2026 21:15
@benoit-cty benoit-cty self-requested a review March 29, 2026 06:58
Copy link
Copy Markdown
Contributor

@benoit-cty benoit-cty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for all these tests !

I just have to minor suggestion.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.82%. Comparing base (6356227) to head (2cb03a4).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1147      +/-   ##
==========================================
+ Coverage   83.10%   88.82%   +5.72%     
==========================================
  Files          45       45              
  Lines        4279     4279              
==========================================
+ Hits         3556     3801     +245     
+ Misses        723      478     -245     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@benoit-cty
Copy link
Copy Markdown
Contributor

For the error, run uv run pre-commit run --all-files to fix pre-commit checks. See https://github.com/mlco2/codecarbon/blob/master/CONTRIBUTING.md#coding-style--linting

Thanks !

@benoit-cty benoit-cty force-pushed the coverage-improvement-plan branch from 432db5f to 2cb03a4 Compare March 30, 2026 11:23
Copy link
Copy Markdown
Contributor

@benoit-cty benoit-cty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, I will merge.

@benoit-cty benoit-cty merged commit 6cf8bcb into mlco2:master Mar 30, 2026
10 checks passed
@benoit-cty benoit-cty mentioned this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants