From 0f5ee86b3884a67f82220b9fd58b493c8f317b16 Mon Sep 17 00:00:00 2001 From: Erik Flodin Date: Thu, 9 Jan 2025 21:59:52 +0100 Subject: [PATCH] test: Make distroy family detection work as in yadm So that family is properly set also on e.g. debian. --- test/conftest.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 0787371..f22e9c2 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -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")