test: dynamically generate stage test_stages
This is a partial revert of commit d584a1e, which converted the
dynamically generate stage tests to sub tests. The problem with
the latter is that they can't be individually run, which makes
testing changes to specific stages cumbersome to develop.
Therefore switch back to a model where the stage tests are
dynamically generated via a class decorator.
This commit is contained in:
parent
428a9fd58c
commit
c616afa87e
1 changed files with 11 additions and 8 deletions
|
|
@ -30,9 +30,20 @@ def find_stage(result, stageid):
|
|||
return None
|
||||
|
||||
|
||||
def make_stage_tests(klass):
|
||||
path = os.path.join(test.TestBase.locate_test_data(), "stages")
|
||||
for t in glob.glob(f"{path}/*/diff.json"):
|
||||
test_path = os.path.dirname(t)
|
||||
test_name = os.path.basename(test_path).replace("-", "_")
|
||||
setattr(klass, f"test_{test_name}",
|
||||
lambda s, path=test_path: s.run_stage_diff_test(path))
|
||||
return klass
|
||||
|
||||
|
||||
@unittest.skipUnless(test.TestBase.have_test_data(), "no test-data access")
|
||||
@unittest.skipUnless(test.TestBase.have_tree_diff(), "tree-diff missing")
|
||||
@unittest.skipUnless(test.TestBase.can_bind_mount(), "root-only")
|
||||
@make_stage_tests
|
||||
class TestStages(test.TestBase):
|
||||
|
||||
def assertTreeDiffsEqual(self, tree_diff1, tree_diff2):
|
||||
|
|
@ -180,14 +191,6 @@ class TestStages(test.TestBase):
|
|||
# the osbuild cache with.
|
||||
osb.copy_source_data(self.store, "org.osbuild.files")
|
||||
|
||||
def test_stages(self):
|
||||
path = os.path.join(self.locate_test_data(), "stages")
|
||||
for t in glob.glob(f"{path}/*/diff.json"):
|
||||
test_path = os.path.dirname(t)
|
||||
test_name = os.path.basename(test_path)
|
||||
with self.subTest(stage=test_name):
|
||||
self.run_stage_diff_test(test_path)
|
||||
|
||||
def test_dracut(self):
|
||||
datadir = self.locate_test_data()
|
||||
base = os.path.join(datadir, "stages/dracut")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue