Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Unit tests on Windows: 13 failures besides the CLI ones in #1459 (one also on any machine with an NVIDIA GPU)

Aperta Adatta ai principianti
#1,460 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@dilipna ci sta già lavorando.

Dal 28/10/2026.

  • #1468 di @dilipna — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
testing

Direzione di ricerca

Inizia con tests/test_rapl_mmio_scanning.py, tests/test_electricitymaps_cache.py e tests/test_emissions_tracker.py; l’issue descrive i casi che falliscono e le correzioni proposte che riguardano solo i test. Leggi i relativi marcatori di skip Linux, il controllo del TTL della cache e la configurazione del mock GPU. Poi esegui i file di test interessati su Windows e, per il caso GPU, con un driver NVIDIA. Il lavoro è completo quando i 13 errori segnalati sono stati corretti e i test passano.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Running the unit tests locally on Windows 11 (Python 3.12, master 24ddb59a, -m 'not integ_test') gives 773 passed, 15 failed, 20 skipped. Two of the 15 are the CLI tests that #1459 fixes (with #1459 applied, tests/cli passes here: 78 passed). CI runs on Linux without a GPU, so the other 13 don't show up there. They fall into three groups, each with a test-only fix that I checked on this machine.

1. Eleven RAPL tests create folders named intel-rapl:0

_make_rapl_tree creates intel-rapl:{index} directories. : is not allowed in Windows file names, so mkdir raises NotADirectoryError: [WinError 267] The directory name is invalid (the same character problem as #79). These tests set sys.platform to "linux" with monkeypatch, while the other RAPL tests in the same file and in test_rapl_parameters.py and test_rapl_permissions.py are skipped off Linux with:

@pytest.mark.skipif(not sys.platform.lower().startswith("lin"), reason="requires Linux")

Adding the same marker would skip them on Windows and change nothing on Linux.

The 11 failing tests (tests/test_rapl_mmio_scanning.py)
  • test_rapl_start_flags_only_nonzero_mirrored_package_counters (3 cases)
  • test_rapl_start_keeps_dram_when_it_matches_a_package_counter
  • test_rapl_start_skips_unreadable_counters
  • test_rapl_start_reevaluates_mirror_candidates
  • test_rapl_confirmed_mirror_is_dropped_after_identical_deltas
  • test_rapl_coincidental_match_is_restored_after_diverging_deltas
  • test_rapl_mirrors_near_counter_wrap_are_still_detected
  • test_rapl_candidate_with_skipped_sample_stays_pending
  • test_rapl_inconclusive_candidate_stays_pending
2. test_expired_cache_entry_is_refetched (Python 3.12 on Windows)

The test patches ELECTRICITYMAPS_CACHE_TTL to 0 and expects the second call to refetch, but the cache check is time.monotonic() - cached[0] <= ELECTRICITYMAPS_CACHE_TTL. On Windows, Python 3.12's time.monotonic() uses GetTickCount64() (resolution 15.6 ms), so two calls within one tick give a difference of exactly 0 and the cached value is returned: 1 request instead of 2. Python 3.13 switched to QueryPerformanceCounter() (0.1 µs), so I'd expect this only on 3.12. Patching the TTL to -1 instead of 0 makes the test independent of the clock; with that change the file passes here (10 passed, 3 runs).

3. test_task_energy_with_live_update_interference (any machine with an NVIDIA driver)

The total energy exceeds the expected 0.00015 kWh by 1.6e-6 to 3.1e-6 kWh depending on the run. The difference is gpu_energy, measured from this laptop's real GPU (gpu_model in the result is the RTX 3050 Ti). TestCarbonTracker patches codecarbon.core.gpu.pynvml with fake_pynvml, but codecarbon/core/gpu.py calls NVML through gpu_nvidia.pynvml, which that patch does not replace, so the test reaches the real driver when one is installed. Adding

@mock.patch("codecarbon.core.gpu_nvidia.pynvml", fake_pynvml)

to the class makes this test pass here, and all 39 tests in tests/test_emissions_tracker.py still pass with it. I expect the same failure on Linux with an NVIDIA GPU, but I only ran it on Windows.

I can send these three changes as one test-only PR if that's useful.

(Checked and drafted with an AI assistant, Claude Code, and reviewed by me.)

Lingua principale
Python
Stelle
1.9k
Fork
347
Merge medio
2g 13h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mlco2/codecarbon

Tutte le issue di mlco2/codecarbon

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.