From: Iker Pedrosa Date: Wed, 12 Mar 2025 13:59:38 +0000 (+0100) Subject: tests/: improve distribution detection X-Git-Tag: 4.18.0-rc1~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=091c91fb11e04dd710eb81130690c9486d169204;p=thirdparty%2Fshadow.git tests/: improve distribution detection openSUSE includes comment lines in `/etc/os-release` file and this can cause some issues during the distribution detection. Ignore those lines as they don't cause any effect on the system. Signed-off-by: Iker Pedrosa Reviewed-by: Dan Lavu --- diff --git a/tests/system/framework/hosts/base.py b/tests/system/framework/hosts/base.py index a5ee5d914..764c15aff 100644 --- a/tests/system/framework/hosts/base.py +++ b/tests/system/framework/hosts/base.py @@ -54,7 +54,8 @@ class BaseLinuxHost(MultihostHost[ShadowMultihostDomain]): """ self.logger.info(f"Detecting distro information on {self.hostname}") os_release = self.fs.read("/etc/os-release") - self._os_release = dict(csv.reader([x for x in os_release.splitlines() if x], delimiter="=")) + valid_lines = [line for line in os_release.splitlines() if line and not line.startswith("#")] + self._os_release = dict(csv.reader(valid_lines, delimiter="=")) if "NAME" in self._os_release: self._distro_name = self._os_release["NAME"] if "VERSION_ID" not in self._os_release: