From dddfbdfe5689bde8cd43a086a530c362de669ccd Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 8 May 2018 14:05:49 -0700 Subject: framework: make use of Filter.run in Profile classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tested-by: Michel Dänzer --- framework/profile.py | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'framework') diff --git a/framework/profile.py b/framework/profile.py index b0233866b..aff0ffa2c 100644 --- a/framework/profile.py +++ b/framework/profile.py @@ -369,17 +369,20 @@ class XMLProfile(object): def _itertests(self): """Always iterates tests instead of using the forced test_list.""" - with gzip.open(self.filename, 'rt') as f: - doc = et.iterparse(f, events=(b'end', )) - _, root = next(doc) # get the root so we can keep clearing it - for _, e in doc: - if e.tag != 'Test': - continue - k = e.attrib['name'] - v = make_test(e) - if all(f(k, v) for f in self.filters): + def _iter(): + with gzip.open(self.filename, 'rt') as f: + doc = et.iterparse(f, events=(b'end', )) + _, root = next(doc) # get the root so we can keep clearing it + for _, e in doc: + if e.tag != 'Test': + continue + k = e.attrib['name'] + v = make_test(e) yield k, v - root.clear() + root.clear() + + for k, v in self.filters.run(_iter()): + yield k, v def itertests(self): if self.forced_test_list: @@ -432,11 +435,14 @@ class MetaProfile(object): pass def _itertests(self): - for p in self._profiles: - for k, v in p.itertests(): - if all(f(k, v) for f in self.filters): + def _iter(): + for p in self._profiles: + for k, v in p.itertests(): yield k, v + for k, v in self.filters.run(_iter()): + yield k, v + def itertests(self): if self.forced_test_list: alltests = dict(self._itertests()) @@ -516,9 +522,8 @@ class TestProfile(object): else: opts = self.test_list # pylint: disable=redefined-variable-type - for k, v in six.iteritems(opts): - if all(f(k, v) for f in self.filters): - yield k, v + for k, v in self.filters.run(six.iteritems(opts)): + yield k, v def load_test_profile(filename, python=None): -- cgit v1.2.3