Rather than require the caller to pass in a parsed XML node, just pass in the filename and have osinfo.py handle it Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- tests/osinfo.py | 6 ++++++ tests/util.py | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/osinfo.py b/tests/osinfo.py index adf451d..e17dc38 100644 --- a/tests/osinfo.py +++ b/tests/osinfo.py @@ -2,6 +2,7 @@ # See the COPYING file in the top-level directory. import re +import xml.etree.ElementTree as ET def _cache_property(fn): @@ -40,6 +41,11 @@ class _XMLBase(): class Os(_XMLBase): + def __init__(self, filename): + self.filename = filename + root = ET.parse(self.filename).getroot().find('os') + super().__init__(root) + def __repr__(self): return "<%s shortid=%s>" % (self.__class__.__name__, self.shortid) diff --git a/tests/util.py b/tests/util.py index a2e88f6..255a78d 100644 --- a/tests/util.py +++ b/tests/util.py @@ -5,7 +5,6 @@ from collections import defaultdict import os import re -import xml.etree.ElementTree as ET import pytest @@ -71,8 +70,7 @@ class _DataFiles(): """ if not self._oses_cache: for path in self._filter_xml('os'): - osroot = ET.parse(path).getroot().find('os') - self._oses_cache.append(osinfo.Os(osroot)) + self._oses_cache.append(osinfo.Os(path)) oses = self._oses_cache[:] if filter_media: -- 2.21.0 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo