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:
parent
1e5612d707
commit
0f5ee86b38
1 changed files with 10 additions and 4 deletions
|
@ -81,13 +81,19 @@ def tst_distro(runner):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def tst_distro_family(runner):
|
def tst_distro_family():
|
||||||
"""Test session's distro_family"""
|
"""Test session's distro_family"""
|
||||||
family = ""
|
family = ""
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
run = runner(command=["grep", "-oP", r"ID_LIKE=\K.+", "/etc/os-release"], report=False)
|
with open("/etc/os-release", encoding="utf-8") as f:
|
||||||
family = run.out.strip()
|
for line in f:
|
||||||
return family
|
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")
|
@pytest.fixture(scope="session")
|
||||||
|
|
Loading…
Reference in a new issue