/
githubmirror
/
salt
Обзор
Документация
Войти
/
githubmirror
/
salt
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tests/pytests/unit/utils/test_vt.py
57 строк
2 KB
Daniel A. Wozniak
Fix macOS/Windows source builds, test package versioning, and flaky tests
21 май 2026, 01:37
21 май 2026, 01:37
6aeb88a
Код
Авторство
О чём код?
import logging import os import signal import pytest import salt.utils.vt as vt @pytest.mark.skip_on_windows(reason="salt.utils.vt.Terminal doesn't have _spawn.") def test_isalive_no_child(): term = vt.Terminal( "sleep 100", shell=True, stream_stdout=False, stream_stderr=False, ) # make sure we have a valid term before we kill the term # commenting out for now, terminal seems to be stopping before this point aliveness = term.isalive() assert term.exitstatus is None assert aliveness is True # use a large hammer to make sure pid is really dead which will cause it to # raise an exception that we want to test for. os.kill(term.pid, signal.SIGKILL) os.waitpid(term.pid, 0) aliveness = term.isalive() assert term.exitstatus == 0 assert aliveness is False @pytest.mark.parametrize("test_cmd", ["echo", "ls"]) @pytest.mark.skip_on_windows() def test_log_sanitize(test_cmd, caplog): """ test when log_sanitize is passed in we do not see the password in either standard out or standard error logs """ password = "123456" cmd = [test_cmd, password] term = vt.Terminal( cmd, log_stdout=True, log_stderr=True, log_stdout_level="debug", log_stderr_level="debug", log_sanitize=password, stream_stdout=False, stream_stderr=False, ) with caplog.at_level(logging.DEBUG): while term.has_unread_data: term.recv() assert password not in caplog.text assert "******" in caplog.text