aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_toml_parser.py
blob: 8c6a905771d152557ced9d1e88b676b7e52d0c09 (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.toml_parser import TomlParser


def test_that_import_error_is_raised_if_no_tomlkit():
    """
    config_file.toml_parser.TomlParser

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

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