aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/pytest
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-12-11 09:19:45 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-12-11 09:35:01 +0300
commit4746be4e7d8a883476160a3756105393f9d5b4f6 (patch)
tree59ecbad9e28805d0618bdf38aabff3c9bf6065a7 /library/python/pytest
parent7bc6ff1b9fca2c3a8e59f0714ae4a15e46faf9c8 (diff)
downloadydb-4746be4e7d8a883476160a3756105393f9d5b4f6.tar.gz
Intermediate changes
commit_hash:a633306b66f89adbf188bf9c6d521bdf7b01f82f
Diffstat (limited to 'library/python/pytest')
-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):