aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_yaml_parser.py
blob: cb25f4d8e19753e470496d0e35fa6161ddd0bebf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from unittest.mock import patch

import pytest

from config_file.parsers.yaml_parser import YamlParser


def test_that_import_error_is_raised_if_no_ruamelyaml():
    """
    config_file.yaml_parser.YamlParser

    Ensure an import error is raised if ruamel.yaml is not
    installed.
    """
    with pytest.raises(ImportError) as error:
        with patch("builtins.__import__") as mock_import:
            mock_import.side_effect = ImportError
            YamlParser("")

    assert (
        "Install the `yaml` extra first with `pip install config-file[yaml]`."
        in str(error)
    )