From b5b4f5a1689a8b331cb873488b06995bbe50f6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 28 Dec 2021 17:25:07 +0100 Subject: [PATCH] use 'build_extractor_filter' in test_results.py --- test/test_results.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/test/test_results.py b/test/test_results.py index 944f14d9..37dea38c 100644 --- a/test/test_results.py +++ b/test/test_results.py @@ -353,28 +353,23 @@ def generate_tests(): # enable selective testing for direct calls if __name__ == '__main__' and len(sys.argv) > 1: - if sys.argv[1].lower() == "all": - fltr = lambda c, bc: True # noqa: E731 - elif sys.argv[1].lower() == "broken": - fltr = lambda c, bc: c in BROKEN # noqa: E731 - else: - argv = sys.argv[1:] - fltr = lambda c, bc: c in argv or bc in argv # noqa: E731 + categories = sys.argv[1:] + negate = False + if categories[0].lower() == "all": + categories = () + negate = True + elif categories[0].lower() == "broken": + categories = BROKEN del sys.argv[1:] else: - skip = set(BROKEN) - if skip: - print("skipping:", ", ".join(skip)) - fltr = lambda c, bc: c not in skip # noqa: E731 - - # filter available extractor classes - extractors = [ - extr for extr in extractor.extractors() - if fltr(extr.category, extr.basecategory) - ] + categories = BROKEN + negate = True + if categories: + print("skipping:", ", ".join(categories)) + fltr = util.build_extractor_filter(categories, negate=negate) # add 'test_...' methods - for extr in extractors: + for extr in filter(fltr, extractor.extractors()): name = "test_" + extr.__name__ + "_" for num, tcase in enumerate(extr._get_tests(), 1): test = _generate_test(extr, tcase)