Skip to content

Commit

Permalink
Fix test_emulate_energy_full_not_avail (#1163)
Browse files Browse the repository at this point in the history
The value may come from two different files, must mock both.
  • Loading branch information
jdufresne authored and giampaolo committed Oct 29, 2017
1 parent 35bd6fd commit fe53d1a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion psutil/tests/test_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,9 @@ def test_emulate_energy_full_not_avail(self):
# Emulate a case where energy_full file does not exist.
# Expected fallback on /capacity.
def open_mock(name, *args, **kwargs):
if name.startswith("/sys/class/power_supply/BAT0/energy_full"):
energy_full = "/sys/class/power_supply/BAT0/energy_full"
charge_full = "/sys/class/power_supply/BAT0/charge_full"
if name.startswith(energy_full) or name.startswith(charge_full):
raise IOError(errno.ENOENT, "")
elif name.startswith("/sys/class/power_supply/BAT0/capacity"):
return io.BytesIO(b"88")
Expand Down

0 comments on commit fe53d1a

Please sign in to comment.