diff options
author | iaz1607 <[email protected]> | 2022-02-10 16:45:37 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:37 +0300 |
commit | 94e51c602b555459333b3c6ae92476c424c930bc (patch) | |
tree | b2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /library/python/testing/filter | |
parent | e5437feb4ac2d2dc044e1090b9312dde5ef197e0 (diff) |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/python/testing/filter')
-rw-r--r-- | library/python/testing/filter/filter.py | 114 | ||||
-rw-r--r-- | library/python/testing/filter/ya.make | 8 |
2 files changed, 61 insertions, 61 deletions
diff --git a/library/python/testing/filter/filter.py b/library/python/testing/filter/filter.py index 2a6e19388ce..a1642bd052f 100644 --- a/library/python/testing/filter/filter.py +++ b/library/python/testing/filter/filter.py @@ -1,57 +1,57 @@ -# coding: utf-8 -# TODO move devtools/ya/test/filter.py to library/python/testing/filter/filter.py -import re -import fnmatch -import logging - -logger = logging.getLogger(__name__) -TEST_SUBTEST_SEPARATOR = '::' - -PARSE_TAG_RE = re.compile("([+-]?[\w:]*)") - - -class FilterException(Exception): - mute = True - - -def fix_filter(flt): - if TEST_SUBTEST_SEPARATOR not in flt and "*" not in flt: - # user wants to filter by test module name - flt = flt + TEST_SUBTEST_SEPARATOR + "*" - return flt - - -def escape_for_fnmatch(s): - return s.replace("[", "[").replace("]", "]") - - -def make_py_file_filter(filter_names): - if filter_names is not None: - with_star = [] - wo_star = set() - for flt in filter_names: - flt = flt.split(':')[0] - if '*' in flt: - with_star.append(flt.split('*')[0] + '*') - else: - wo_star.add(flt) - - def predicate(filename): - if filter_names is None: - return True - return filename in wo_star or any([fnmatch.fnmatch(escape_for_fnmatch(filename), escape_for_fnmatch(filter_name)) for filter_name in with_star]) - - return predicate - - -def make_name_filter(filter_names): - filter_names = map(fix_filter, filter_names) - filter_full_names = set() - for name in filter_names: - if '*' not in name: - filter_full_names.add(name) - - def predicate(testname): - return testname in filter_full_names or any([fnmatch.fnmatch(escape_for_fnmatch(testname), escape_for_fnmatch(filter_name)) for filter_name in filter_names]) - - return predicate +# coding: utf-8 +# TODO move devtools/ya/test/filter.py to library/python/testing/filter/filter.py +import re +import fnmatch +import logging + +logger = logging.getLogger(__name__) +TEST_SUBTEST_SEPARATOR = '::' + +PARSE_TAG_RE = re.compile("([+-]?[\w:]*)") + + +class FilterException(Exception): + mute = True + + +def fix_filter(flt): + if TEST_SUBTEST_SEPARATOR not in flt and "*" not in flt: + # user wants to filter by test module name + flt = flt + TEST_SUBTEST_SEPARATOR + "*" + return flt + + +def escape_for_fnmatch(s): + return s.replace("[", "[").replace("]", "]") + + +def make_py_file_filter(filter_names): + if filter_names is not None: + with_star = [] + wo_star = set() + for flt in filter_names: + flt = flt.split(':')[0] + if '*' in flt: + with_star.append(flt.split('*')[0] + '*') + else: + wo_star.add(flt) + + def predicate(filename): + if filter_names is None: + return True + return filename in wo_star or any([fnmatch.fnmatch(escape_for_fnmatch(filename), escape_for_fnmatch(filter_name)) for filter_name in with_star]) + + return predicate + + +def make_name_filter(filter_names): + filter_names = map(fix_filter, filter_names) + filter_full_names = set() + for name in filter_names: + if '*' not in name: + filter_full_names.add(name) + + def predicate(testname): + return testname in filter_full_names or any([fnmatch.fnmatch(escape_for_fnmatch(testname), escape_for_fnmatch(filter_name)) for filter_name in filter_names]) + + return predicate diff --git a/library/python/testing/filter/ya.make b/library/python/testing/filter/ya.make index a23d1459214..22c485d2580 100644 --- a/library/python/testing/filter/ya.make +++ b/library/python/testing/filter/ya.make @@ -1,5 +1,5 @@ -PY23_LIBRARY() +PY23_LIBRARY() OWNER(g:yatest) -PY_SRCS(filter.py) - -END() +PY_SRCS(filter.py) + +END() |