From 55e6dd16aa6a9e3711847ce1f8030a5afe44bb86 Mon Sep 17 00:00:00 2001 From: Michal Polovka Date: Fri, 27 May 2022 13:06:16 +0200 Subject: [PATCH] experiment --- tests/test_options.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/test_options.py b/tests/test_options.py index b00707f9..595da80c 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -4,11 +4,14 @@ import argparse import io +import logging import os import tempfile -from contextlib import redirect_stdout, redirect_stderr +from contextlib import redirect_stdout from unittest.mock import patch +import pytest + from ipahealthcheck.core.core import RunChecks from ipahealthcheck.core.plugin import Results @@ -109,7 +112,8 @@ def test_incorrect_output_type_cfg_file(mock_parse, mock_run, mock_service): @patch('ipahealthcheck.core.core.run_service_plugins') @patch('ipahealthcheck.core.core.run_plugins') @patch('ipahealthcheck.core.core.parse_options') -def test_incorrect_delimiter_cfg_file(mock_parse, mock_run, mock_service): +def test_incorrect_delimiter_cfg_file(mock_parse, mock_run, mock_service, + caplog): """ Test the error message is user-friendly if the incorrect delimiter is used in cfg file @@ -128,11 +132,10 @@ def test_incorrect_delimiter_cfg_file(mock_parse, mock_run, mock_service): try: run = RunChecks([], config_path) - f = io.StringIO() - with redirect_stderr(f): + with caplog.at_level(logging.ERROR): run.run_healthcheck() - assert "contains parsing errors" in f.getvalue() + assert "contains parsing errors" in caplog.text finally: os.remove(config_path)