/
githubmirror
/
salt
Обзор
Документация
Войти
/
githubmirror
/
salt
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tests/pytests/pkg/integration/test_python.py
72 строки
2 KB
David Murphy
Adjusted tests for classic or relenv, as everything is relenv now
16 авг 2024, 00:49
16 авг 2024, 00:49
f3a7083
Код
Авторство
О чём код?
import subprocess import textwrap import pytest @pytest.fixture def python_script_bin(install_salt): return install_salt.binary_paths["python"] @pytest.fixture def check_python_file(tmp_path): script_path = tmp_path / "check_python.py" script_path.write_text( textwrap.dedent( """ import sys import salt.utils.data user_arg = sys.argv if user_arg[1] == "raise": raise Exception("test") if salt.utils.data.is_true(user_arg[1]): sys.exit(0) else: sys.exit(1) """ ) ) return script_path @pytest.mark.parametrize("exp_ret,user_arg", [(1, "false"), (0, "true")]) def test_python_script( install_salt, exp_ret, user_arg, python_script_bin, check_python_file ): ret = install_salt.proc.run( *( python_script_bin + [ str(check_python_file), user_arg, ] ), stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False, universal_newlines=True, ) assert ret.returncode == exp_ret, ret.stderr def test_python_script_exception(install_salt, python_script_bin, check_python_file): ret = install_salt.proc.run( *( python_script_bin + [ str(check_python_file), "raise", ] ), stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False, universal_newlines=True, ) assert "Exception: test" in ret.stderr