Skip to content

Coverage improvement plan#1147

Open
DiogoRibeiro7 wants to merge 4 commits intomlco2:masterfrom
DiogoRibeiro7:coverage-improvement-plan
Open

Coverage improvement plan#1147
DiogoRibeiro7 wants to merge 4 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
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.

1 participant