Skip to content

Commit

Permalink
experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
miskopo committed May 27, 2022
1 parent dd98739 commit 55e6dd1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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)

0 comments on commit 55e6dd1

Please sign in to comment.