diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-12-12 15:00:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-12 15:00:43 +0000 |
commit | 42701242eaf5be980cb935631586d0e90b82641c (patch) | |
tree | 6dbf5fcd37d3c16591e196c4a69d166e3ab3a398 /library/python | |
parent | 7f5a9f394dbd9ac290cabbb7977538656b3a541e (diff) | |
parent | f7c04b5876af3d16849ab5e3079c0eabbd4e3a00 (diff) | |
download | ydb-42701242eaf5be980cb935631586d0e90b82641c.tar.gz |
Merge pull request #12554 from vitalyisaev2/YQ-3839.with_rightlib.3
Import from Arcadia + YDB FQ: turning gateways_config.proto into a file without external dependencies
Diffstat (limited to 'library/python')
-rw-r--r-- | library/python/pytest/plugins/collection.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/library/python/pytest/plugins/collection.py b/library/python/pytest/plugins/collection.py index aa3f51cfef..7ca8efc47e 100644 --- a/library/python/pytest/plugins/collection.py +++ b/library/python/pytest/plugins/collection.py @@ -85,20 +85,32 @@ class DoctestModule(LoadedModule): reraise(etype, type(exc)('{}\n{}'.format(exc, msg)), tb) +def _is_skipped_module_level(module): + # since we import module by ourselves when CONFTEST_LOAD_POLICY is set to LOCAL we have to handle + # pytest.skip.Exception https://docs.pytest.org/en/stable/reference/reference.html#pytest-skip + try: + module.obj + except pytest.skip.Exception: + return True + except Exception: + # letting other exceptions such as ImportError slip through + pass + return False + + # NOTE: Since we are overriding collect method of pytest session, pytest hooks are not invoked during collection. def pytest_ignore_collect(module, session, filenames_from_full_filters, accept_filename_predicate): if session.config.option.mode == 'list': - return not accept_filename_predicate(module.name) + return not accept_filename_predicate(module.name) or _is_skipped_module_level(module) if filenames_from_full_filters is not None and module.name not in filenames_from_full_filters: return True test_file_filter = getattr(session.config.option, 'test_file_filter', None) - if test_file_filter is None: - return False - if module.name != test_file_filter.replace('/', '.'): + if test_file_filter and module.name != test_file_filter.replace('/', '.'): return True - return False + + return _is_skipped_module_level(module) class CollectionPlugin(object): |