aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_toml_parser.py24
-rw-r--r--tests/test_yaml_parser.py24
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/test_toml_parser.py b/tests/test_toml_parser.py
index e69de29..845e78e 100644
--- a/tests/test_toml_parser.py
+++ b/tests/test_toml_parser.py
@@ -0,0 +1,24 @@
+from unittest.mock import patch
+
+import pytest
+
+from config_file.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)
+ )
diff --git a/tests/test_yaml_parser.py b/tests/test_yaml_parser.py
index e69de29..1f46692 100644
--- a/tests/test_yaml_parser.py
+++ b/tests/test_yaml_parser.py
@@ -0,0 +1,24 @@
+from unittest.mock import patch
+
+import pytest
+
+from config_file.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)
+ )