aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-12-11 09:19:45 +0300
committerVitaly Isaev <vitalyisaev@ydb.tech>2024-12-12 10:12:04 +0000
commit938ea459be4fdc89e6da0994a9f989e55e0eb56a (patch)
treeece2ebb5fbcafaacded2215c05e4543aa70d9551
parentd953e908eb505c97ee8cb0818be5a711545c9e94 (diff)
downloadydb-938ea459be4fdc89e6da0994a9f989e55e0eb56a.tar.gz
Intermediate changes
commit_hash:a633306b66f89adbf188bf9c6d521bdf7b01f82f
-rw-r--r--library/python/pytest/plugins/collection.py22
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):