Skip to content

Commit

Permalink
test: Robustify powerprofilesctl version parsing
Browse files Browse the repository at this point in the history
https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/merge_requests/167
will change the output of `powerprofilesctl version`. Take the
first version number from the ouput instead of assuming that the output
starts with it.
  • Loading branch information
martinpitt committed Feb 26, 2024
1 parent b24f7b7 commit 7bf34be
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/test_power_profiles_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import fcntl
import os
import re
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -40,9 +41,10 @@ def setUpClass(cls):
def setUp(self):
# depending on the installed client version, we need to pick the right template
try:
version = subprocess.run(
out = subprocess.run(
["powerprofilesctl", "version"], capture_output=True, text=True, check=True
).stdout
version = re.search(r'[0-9.]+', out).group(0)
version = ".".join(version.strip().split(".")[:2])
template = "power_profiles_daemon" if float(version) < 0.2 else "upower_power_profiles_daemon"
except subprocess.CalledProcessError as e:
Expand Down

0 comments on commit 7bf34be

Please sign in to comment.