debian-forge/test/test_osrelease.py
David Rheinsberg 53415a3cbc pipeline: detect_os() -> describe_os()
Rename the function to `describe_os()`. We do no actual detection, nor
verification here. That is, the return value of this function is in no
way guaranteed to be a valid runner. That is, error-handling needs to
be done in the caller. Make this clear by renaming the function.

Note: Currently, in case no runner exists for the OS, we end up with:

          execv(...) failed: No such file or directory

      This needs to be fixed in the future.
2020-02-29 12:35:19 +01:00

18 lines
596 B
Python

import os
import unittest
import osbuild
class TestOSRelease(unittest.TestCase):
def test_non_existant(self):
"""Verify default os-release value, if no files are given."""
self.assertEqual(osbuild.pipeline.describe_os(), "linux")
def test_describe_os(self):
"""Test host os detection. test/os-release contains the os-release files
for all supported runners.
"""
for entry in os.scandir("test/os-release"):
with self.subTest(entry.name):
self.assertEqual(osbuild.pipeline.describe_os(entry.path), entry.name)