This drops the total isoinfo runtime from ~80 seconds to about ~6 on my machine. Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- tests/osinfo.py | 11 ++++++----- tests/test_isoinfo.py | 16 ++++------------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/tests/osinfo.py b/tests/osinfo.py index 295bac3..2950306 100644 --- a/tests/osinfo.py +++ b/tests/osinfo.py @@ -2,8 +2,9 @@ # See the COPYING file in the top-level directory. from http.client import responses - import logging +import re + import requests @@ -126,19 +127,19 @@ class ISO(): return return_type(entry.text) if entry is not None else default def _get_volumeid(self): - return self._get_value('volume-id') + return re.compile(self._get_value('volume-id')) volumeid = _cache_property(_get_volumeid) def _get_publisherid(self): - return self._get_value('publisher-id') + return re.compile(self._get_value('publisher-id')) publisherid = _cache_property(_get_publisherid) def _get_applicationid(self): - return self._get_value('application-id') + return re.compile(self._get_value('application-id')) applicationid = _cache_property(_get_applicationid) def _get_systemid(self): - return self._get_value('system-id') + return re.compile(self._get_value('system-id')) systemid = _cache_property(_get_systemid) def _get_volumesize(self): diff --git a/tests/test_isoinfo.py b/tests/test_isoinfo.py index 8440bb2..6de7c1d 100644 --- a/tests/test_isoinfo.py +++ b/tests/test_isoinfo.py @@ -3,7 +3,6 @@ import logging import os -import re import pytest from . import util @@ -58,21 +57,14 @@ class _ISODataMedia(): self.volumesize = volumesize if volumesize is not None else 0 def match(self, media): - if media.volumeid == '' and \ - media.systemid == '' and \ - media.publisherid == '' and \ - media.applicationid == '' and \ - media.volumesize == 0: - return False - volumesize = media.volumesize if volumesize == 0: volumesize = self.volumesize - if bool(re.match(media.volumeid, self.volumeid)) and \ - bool(re.match(media.publisherid, self.publisherid)) and \ - bool(re.match(media.applicationid, self.applicationid)) and \ - bool(re.match(media.systemid, self.systemid)) and \ + if bool(media.volumeid.match(self.volumeid)) and \ + bool(media.publisherid.match(self.publisherid)) and \ + bool(media.applicationid.match(self.applicationid)) and \ + bool(media.systemid.match(self.systemid)) and \ volumesize == self.volumesize: return True -- 2.21.0 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo