diff options
| author | bulatman <[email protected]> | 2025-11-17 20:14:59 +0300 |
|---|---|---|
| committer | bulatman <[email protected]> | 2025-11-17 21:07:40 +0300 |
| commit | 24ced9c2cfd9eebd0ce3ede31ab129b21feb8af7 (patch) | |
| tree | 844afeb5fbedd6070712c14c5983bcf7d21a6399 /library/python/pytest | |
| parent | 33a1dabce85cfd5521897238e4c19877f3f0fa11 (diff) | |
Run tests in parallel within node
Support `PARALLEL_TESTS_WITHIN_NODE(X)` for pytest
commit_hash:b515a9f8f27172b546f92415835a8d6c9070d073
Diffstat (limited to 'library/python/pytest')
| -rw-r--r-- | library/python/pytest/plugins/ya.py | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py index 8b763af783b..931585a0e6e 100644 --- a/library/python/pytest/plugins/ya.py +++ b/library/python/pytest/plugins/ya.py @@ -1,17 +1,17 @@ # coding: utf-8 import base64 +import collections import errno -import sys -import os -import logging import fnmatch +import inspect import json +import logging +import os +import signal +import sys import time import traceback -import collections -import signal -import inspect import warnings import faulthandler @@ -136,7 +136,7 @@ def setup_logging(log_path, level=logging.DEBUG, *other_logs): root_logger.setLevel(level) for log_file in logs: file_handler = YaTestLoggingFileHandler(log_file) - log_format = '%(asctime)s - %(levelname)s - %(name)s - %(funcName)s: %(message)s' + log_format = '%(asctime)s - %(levelname)s - %(name)s.%(process)d - %(funcName)s: %(message)s' file_handler.setFormatter(_TokenFilterFormatter(log_format)) file_handler.setLevel(level) root_logger.addHandler(file_handler) @@ -166,6 +166,7 @@ def pytest_addoption(parser): parser.addoption("--python-path", action="store", dest="python_path", default="", help="path the canonical python binary") parser.addoption("--valgrind-path", action="store", dest="valgrind_path", default="", help="path the canonical valgring binary") parser.addoption("--test-filter", action="append", dest="test_filter", default=None, help="test filter") + parser.addoption("--test-filter-file", action="store", dest="test_filter_file", default=None, help="file with test filters") parser.addoption("--test-file-filter", action="store", dest="test_file_filter", default=None, help="test file filter") parser.addoption("--test-param", action="append", dest="test_params", default=None, help="test parameters") parser.addoption("--test-log-level", action="store", dest="test_log_level", choices=["critical", "error", "warning", "info", "debug"], default="debug", help="test log level") @@ -401,6 +402,16 @@ def _get_item_tags(item): return tags +def get_test_filter(option): + filters = [] + if option.test_filter_file: + with open(option.test_filter_file, 'r') as fd: + filters = fd.read().splitlines() + if option.test_filter: + filters.extend(option.test_filter) + return filters + + def pytest_runtest_setup(item): item.rusage = _get_rusage() pytest_config.test_cores_count = 0 @@ -491,8 +502,10 @@ def pytest_collection_modifyitems(items, config): filters = chunks[config.option.modulo_index] filter_by_full_name(filters) else: - if config.option.test_filter: - filter_items(config.option.test_filter) + test_filter = get_test_filter(config.option) + if test_filter: + filter_items(test_filter) + partition_mode = config.option.partition_mode modulo = config.option.modulo if modulo > 1: |
