summaryrefslogtreecommitdiffstats
path: root/library/python/testing
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2026-03-31 01:21:35 +0300
committerrobot-piglet <[email protected]>2026-03-31 01:46:54 +0300
commit552b524f032e5fafcb6e941724e9aaec5bbde901 (patch)
treecdd14077f6939139aa647a8a8d85a4e39cbceb62 /library/python/testing
parentf42912f4c22e288308c47d072a5564899752ed0d (diff)
Intermediate changes
commit_hash:c6aef447a589e761372dc7008458b23a60c4d3f6
Diffstat (limited to 'library/python/testing')
-rw-r--r--library/python/testing/yatest_common/yatest/common/benchmark.py1
-rw-r--r--library/python/testing/yatest_common/yatest/common/canonical.py3
-rw-r--r--library/python/testing/yatest_common/yatest/common/path.py1
-rw-r--r--library/python/testing/yatest_common/yatest/common/process.py15
-rw-r--r--library/python/testing/yatest_common/yatest/common/runtime.py16
-rw-r--r--library/python/testing/yatest_lib/external.py3
-rw-r--r--library/python/testing/yatest_lib/tools.py2
7 files changed, 35 insertions, 6 deletions
diff --git a/library/python/testing/yatest_common/yatest/common/benchmark.py b/library/python/testing/yatest_common/yatest/common/benchmark.py
index c3784cbe4c0..91969e74c1b 100644
--- a/library/python/testing/yatest_common/yatest/common/benchmark.py
+++ b/library/python/testing/yatest_common/yatest/common/benchmark.py
@@ -7,6 +7,7 @@ from . import runtime
def execute_benchmark(path, budget=None, threads=None):
"""
Run benchmark and return values
+
:param path: path to benchmark binary
:param budget: time budget, sec (supported only by ybenchmark)
:param threads: number of threads to run benchmark (supported only by ybenchmark)
diff --git a/library/python/testing/yatest_common/yatest/common/canonical.py b/library/python/testing/yatest_common/yatest/common/canonical.py
index 57467b75d35..a64fdedbfe1 100644
--- a/library/python/testing/yatest_common/yatest/common/canonical.py
+++ b/library/python/testing/yatest_common/yatest/common/canonical.py
@@ -29,6 +29,7 @@ def canonical_file(
):
"""
Create canonical file that can be returned from a test
+
:param path: path to the file
:param diff_tool: custom diff tool to use for comparison with the canonical one, if None - default will be used
:param local: save file locally, otherwise move to sandbox
@@ -90,6 +91,7 @@ def canonical_execute(
):
"""
Shortcut to execute a binary and canonize its stdout
+
:param binary: absolute path to the binary
:param args: binary arguments
:param check_exit_code: will raise ExecutionError if the command exits with non zero code
@@ -158,6 +160,7 @@ def canonical_py_execute(
):
"""
Shortcut to execute a python script and canonize its stdout
+
:param script_path: path to the script arcadia relative
:param args: script arguments
:param check_exit_code: will raise ExecutionError if the command exits with non zero code
diff --git a/library/python/testing/yatest_common/yatest/common/path.py b/library/python/testing/yatest_common/yatest/common/path.py
index 6fed7dda8a9..96b2e1d48a9 100644
--- a/library/python/testing/yatest_common/yatest/common/path.py
+++ b/library/python/testing/yatest_common/yatest/common/path.py
@@ -11,6 +11,7 @@ import library.python.fs as lpf
def replace_in_file(path, old, new):
"""
Replace text occurrences in a file
+
:param path: path to the file
:param old: text to replace
:param new: replacement
diff --git a/library/python/testing/yatest_common/yatest/common/process.py b/library/python/testing/yatest_common/yatest/common/process.py
index e9d72751ef6..ca6025d5a08 100644
--- a/library/python/testing/yatest_common/yatest/common/process.py
+++ b/library/python/testing/yatest_common/yatest/common/process.py
@@ -498,6 +498,7 @@ def execute(
):
"""
Executes a command
+
:param command: command: can be a list of arguments or a string
:param check_exit_code: will raise ExecutionError if the command exits with non zero code
:param shell: use shell to run the command
@@ -511,13 +512,13 @@ def execute(
:type text: bool
:param creationflags: command creation flags
:param wait: should wait until the command finishes
- :param process_progress_listener=object that is polled while execution is in progress
- :param close_fds: subrpocess.Popen close_fds args
+ :param process_progress_listener: object that is polled while execution is in progress
+ :param close_fds: subprocess.Popen close_fds args
:param collect_cores: recover core dump files if shell == False
:param check_sanitizer: raise ExecutionError if stderr contains sanitize errors
- :param preexec_fn: subrpocess.Popen preexec_fn arg
+ :param preexec_fn: subprocess.Popen preexec_fn arg
:param on_timeout: on_timeout(<execution object>, <timeout value>) callback
- :param popen_kwargs: subrpocess.Popen args dictionary. Useful for python3-only arguments
+ :param popen_kwargs: subprocess.Popen args dictionary. Useful for python3-only arguments
:return _Execution: Execution object
"""
@@ -708,6 +709,7 @@ def py_execute(
):
"""
Executes a command with the arcadia python
+
:param command: command to pass to python
:param check_exit_code: will raise ExecutionError if the command exits with non zero code
:param shell: use shell to run the command
@@ -719,7 +721,7 @@ def py_execute(
:param stderr: command stderr
:param creationflags: command creation flags
:param wait: should wait until the command finishes
- :param process_progress_listener=object that is polled while execution is in progress
+ :param process_progress_listener: object that is polled while execution is in progress
:param text: Return original str
:return _Execution: Execution object
"""
@@ -767,7 +769,8 @@ def wait_for(check_function, timeout, fail_message="", sleep_time=1.0, on_check_
def _kill_process_tree(process_pid, target_pid_signal=None):
"""
Kills child processes, req. Note that psutil should be installed
- @param process_pid: parent id to search for descendants
+
+ :param process_pid: parent id to search for descendants
"""
yatest_logger.debug("Killing process %s", process_pid)
if os.name == 'nt':
diff --git a/library/python/testing/yatest_common/yatest/common/runtime.py b/library/python/testing/yatest_common/yatest/common/runtime.py
index e3013e1d4d0..fe5ec573dcb 100644
--- a/library/python/testing/yatest_common/yatest/common/runtime.py
+++ b/library/python/testing/yatest_common/yatest/common/runtime.py
@@ -118,6 +118,7 @@ def _join_path(main_path, path):
def not_test(func):
"""
Mark any function as not a test for py.test
+
:param func:
:return:
"""
@@ -134,6 +135,7 @@ def not_test(func):
def source_path(path=None):
"""
Get source path inside arcadia
+
:param path: path arcadia relative, e.g. yatest.common.source_path('devtools/ya')
:return: absolute path to the source folder
"""
@@ -144,6 +146,7 @@ def source_path(path=None):
def build_path(path=None):
"""
Get path inside build directory
+
:param path: path relative to the build directory, e.g. yatest.common.build_path('devtools/ya/bin')
:return: absolute path inside build directory
"""
@@ -153,6 +156,7 @@ def build_path(path=None):
def java_path():
"""
[DEPRECATED] Get path to java
+
:return: absolute path to java
"""
from . import runtime_java
@@ -186,6 +190,7 @@ def java_bin():
def data_path(path=None):
"""
Get path inside atd_ro_snapshot directory
+
:param path: path relative to the atd_ro_snaphot directory, e.g. yatest.common.data_path("pers/rerank_service")
:return: absolute path in arcadia
"""
@@ -196,7 +201,9 @@ def data_path(path=None):
def output_path(path=None):
"""
Get path inside the current test suite output dir.
+
Placing files to this dir guarantees that files will be accessible after the test suite execution.
+
:param path: path relative to the test suite output dir
:return: absolute path inside the test suite output dir
"""
@@ -219,7 +226,9 @@ def ram_drive_path(path=None):
def output_ram_drive_path(path=None):
"""
Returns path inside ram drive directory which will be saved in the testing_out_stuff directory after testing.
+
Returns None if no ram drive was provided by environment.
+
:param path: path relative to the output ram drive directory
"""
if 'YA_TEST_OUTPUT_RAM_DRIVE_PATH' in os.environ:
@@ -232,6 +241,7 @@ def output_ram_drive_path(path=None):
def binary_path(path=None):
"""
Get path to the built binary
+
:param path: path to the binary relative to the build directory e.g. yatest.common.binary_path('devtools/ya/bin/ya-bin')
:return: absolute path to the binary
"""
@@ -244,6 +254,7 @@ def work_path(path=None):
"""
Get path inside the current test suite working directory. Creating files in the work directory does not guarantee
that files will be accessible after the test suite execution
+
:param path: path relative to the test suite working dir
:return: absolute path inside the test suite working dir
"""
@@ -261,6 +272,7 @@ def python_path():
are built in a stripped-down form that is needed for building, not running tests.
See comments in the file below to find out which version of python is compatible with tests.
https://a.yandex-team.ru/arc/trunk/arcadia/build/platform/python/resources.inc
+
:return: absolute path to python
"""
return _get_ya_plugin_instance().python_path
@@ -270,6 +282,7 @@ def python_path():
def valgrind_path():
"""
Get path to valgrind
+
:return: absolute path to valgrind
"""
return _get_ya_plugin_instance().valgrind_path
@@ -279,6 +292,7 @@ def valgrind_path():
def get_param(key, default=None):
"""
Get arbitrary parameter passed via command line
+
:param key: key
:param default: default value
:return: parameter value or the default
@@ -290,6 +304,7 @@ def set_metric_value(name, val):
"""
Use this method only when your test environment does not support pytest fixtures,
otherwise you should prefer using https://docs.yandex-team.ru/ya-make/manual/tests/#python
+
:param name: name
:param val: value
"""
@@ -301,6 +316,7 @@ def get_metric_value(name, default=None):
"""
Use this method only when your test environment does not support pytest fixtures,
otherwise you should prefer using https://docs.yandex-team.ru/ya-make/manual/tests/#python
+
:param name: name
:param default: default
:return: parameter value or the default
diff --git a/library/python/testing/yatest_lib/external.py b/library/python/testing/yatest_lib/external.py
index 2863579ee81..64d74b5ccf8 100644
--- a/library/python/testing/yatest_lib/external.py
+++ b/library/python/testing/yatest_lib/external.py
@@ -43,6 +43,7 @@ def _do_apply(func, value, apply_to_keys, value_path):
def apply(func, value, apply_to_keys=False):
"""
Applies func to every possible member of value
+
:param value: could be either a primitive object or a complex one (list, dicts)
:param func: func to be applied
:return:
@@ -61,7 +62,9 @@ def is_coroutine(val):
def serialize(value):
"""
Serialize value to json-convertible object
+
Ensures that all components of value can be serialized to json
+
:param value: object to be serialized
"""
def _serialize(val, _):
diff --git a/library/python/testing/yatest_lib/tools.py b/library/python/testing/yatest_lib/tools.py
index 48acbcf278a..ceb303b9210 100644
--- a/library/python/testing/yatest_lib/tools.py
+++ b/library/python/testing/yatest_lib/tools.py
@@ -5,6 +5,7 @@ import sys
def to_utf8(value):
"""
Converts value to string encoded into utf-8
+
:param value:
:return:
"""
@@ -23,6 +24,7 @@ def trim_string(s, max_bytes):
Adjusts the length of the string s in order to fit it
into max_bytes bytes of storage after encoding as UTF-8.
Useful when cutting filesystem paths.
+
:param s: unicode string
:param max_bytes: number of bytes
:return the prefix of s