mlco2 / codecarbon

Track emissions from Compute and recommend ways to reduce their impact on the environment.
https://mlco2.github.io/codecarbon
MIT License
1.18k stars 178 forks source link

[unit tests] is_powermetrics_available stops the run to ask for `sudo` #565

Closed inimaz closed 5 months ago

inimaz commented 6 months ago

I am using linux system. When I ran the unit tests, when it arrives to test_powermetrics.py, it asks for sudo permissions to run it.

tests/test_powermetrics.py::TestApplePowerMetrics::test_get_details [sudo] password for inigo: 
Sorry, try again.
[sudo] password for inigo: 
...

How to reproduce

Run hatch run test:package

benoit-cty commented 5 months ago

Thanks ! I'm having the same problem under Linux. But as it doesn't happened in CI I though it was a local problem.

benoit-cty commented 5 months ago

I think it's [this line](def _has_powermetrics_sudo():) that don't work as expected : if re.search(r"[sudo].*password", stderr):

Solution proposal : https://github.com/mlco2/codecarbon/pull/576