1
0
Fork 0
mirror of synced 2025-01-20 19:19:47 -05:00

test: Make distroy family detection work as in yadm

So that family is properly set also on e.g. debian.
This commit is contained in:
Erik Flodin 2025-01-09 21:59:52 +01:00
parent 1e5612d707
commit 0f5ee86b38
No known key found for this signature in database
GPG key ID: 420A7C865EE3F85F

View file

@ -81,13 +81,19 @@ def tst_distro(runner):
@pytest.fixture(scope="session")
def tst_distro_family(runner):
def tst_distro_family():
"""Test session's distro_family"""
family = ""
with contextlib.suppress(Exception):
run = runner(command=["grep", "-oP", r"ID_LIKE=\K.+", "/etc/os-release"], report=False)
family = run.out.strip()
return family
with open("/etc/os-release", encoding="utf-8") as f:
for line in f:
if line.startswith("ID_LIKE="):
family = line[8:]
break
if line.startswith("ID="):
family = line[3:]
# No break, only used as fallback in case ID_LIKE isn't found
return family.replace('"', "").rstrip()
@pytest.fixture(scope="session")