test: convert os-release-tests to test-data

Use the new `locate_test_data()` helper to get access to test-data.
Guard the test with `have_test_data()` to skip it in case test-data
access is not available.
This commit is contained in:
David Rheinsberg 2020-05-06 11:32:55 +02:00
parent 5c0e6f5964
commit b830bb7480
10 changed files with 5 additions and 2 deletions

View file

@ -7,16 +7,19 @@ import unittest
from osbuild.util import osrelease
from .. import test
class TestUtilOSRelease(unittest.TestCase):
class TestUtilOSRelease(test.TestBase, unittest.TestCase):
def test_non_existant(self):
"""Verify default os-release value, if no files are given."""
self.assertEqual(osrelease.describe_os(), "linux")
@unittest.skipUnless(test.TestBase.have_test_data(), "no test-data access")
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"):
for entry in os.scandir(os.path.join(self.locate_test_data(), "os-release")):
with self.subTest(entry.name):
self.assertEqual(osrelease.describe_os(entry.path), entry.name)