aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2020-06-20 13:41:35 -0500
committerEugene Triguba <eugenetriguba@gmail.com>2020-06-20 15:56:19 -0500
commitaa44fe7a60a4f3326cc47877b3e246b56d46d6ac (patch)
treec30961887bf720ba8c676250174318029f0ad786 /tests
parentCreate python-package-ci.yml (diff)
downloadconfig-file-aa44fe7a60a4f3326cc47877b3e246b56d46d6ac.zip
Add python 3.5 support, ConfigFileError, and more type hints
Also, get_all, set_all, and delete_all in JsonParser have been renamed to just all.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_config_file.py11
-rw-r--r--tests/test_ini_parser.py3
-rw-r--r--tests/test_json_parser.py11
3 files changed, 13 insertions, 12 deletions
diff --git a/tests/test_config_file.py b/tests/test_config_file.py
index f083538..fe8539f 100644
--- a/tests/test_config_file.py
+++ b/tests/test_config_file.py
@@ -3,8 +3,7 @@ from pathlib import Path
import pytest
-from config_file.config_file import ConfigFile
-from config_file.parsers.base_parser import BaseParser
+from config_file import ConfigFile, BaseParser
@pytest.mark.parametrize(
@@ -49,14 +48,14 @@ def test_missing_config_files_during_restore(
tmpdir, file_extension, specify_original_config_path
):
with pytest.raises(OSError):
- temp_path = tmpdir / f"config.{file_extension}"
+ temp_path = tmpdir / "config.{}".format(file_extension)
temp_path.write("")
config = ConfigFile(str(temp_path))
if specify_original_config_path:
- specify_original_config_path = f"does_not_exist.{file_extension}"
+ specify_original_config_path = "does_not_exist.{}".format(file_extension)
else:
- config.path = f"does_not_exist.{file_extension}"
+ config.path = "does_not_exist.{}".format(file_extension)
specify_original_config_path = None
config.restore_original(original_file_path=specify_original_config_path)
@@ -160,7 +159,7 @@ def test_that_config_file_can_get(
def test_that_config_file_can_find_sections_and_keys(
tmpdir, file_extension, file_contents, section_key, expected_result
):
- config_path = tmpdir / f"config.{file_extension}"
+ config_path = tmpdir / "config.{}".format(file_extension)
config_path.write_text(file_contents, encoding="utf-8")
config = ConfigFile(str(config_path))
assert config.has(section_key) == expected_result
diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py
index 7cdeea8..1b2fd3b 100644
--- a/tests/test_ini_parser.py
+++ b/tests/test_ini_parser.py
@@ -1,6 +1,7 @@
import pytest
-from config_file.parsers.ini_parser import IniParser, ParsingError
+from config_file.parsers.ini_parser import IniParser
+from config_file.exceptions import ParsingError
@pytest.mark.parametrize("ini_file", ["blahblahblah", "{ 'key1': 5 }"])
diff --git a/tests/test_json_parser.py b/tests/test_json_parser.py
index a5e38a1..9a8ac09 100644
--- a/tests/test_json_parser.py
+++ b/tests/test_json_parser.py
@@ -2,7 +2,8 @@ import json
import pytest
-from config_file.parsers.json_parser import JsonParser, ParsingError
+from config_file.parsers.json_parser import JsonParser
+from config_file.exceptions import ParsingError
@pytest.mark.parametrize("test_json", ["{'test': }", "[section]\nblah = value\n\n"])
@@ -162,7 +163,7 @@ def test_that_json_parser_can_delete_keys(key, test_json, expected_json):
)
def test_that_json_parser_can_retrieve_all_keys(test_json, key, expected_output):
parser = JsonParser(json.dumps(test_json))
- assert parser.get(key, get_all=True) == expected_output
+ assert parser.get(key, all=True) == expected_output
@pytest.mark.parametrize(
@@ -178,8 +179,8 @@ def test_that_json_parser_can_retrieve_all_keys(test_json, key, expected_output)
)
def test_that_json_parser_can_set_all_keys(test_json, key, value, expected_output):
parser = JsonParser(json.dumps(test_json))
- parser.set(key, value, set_all=True)
- assert parser.get(key, get_all=True) == expected_output
+ parser.set(key, value, all=True)
+ assert parser.get(key, all=True) == expected_output
@pytest.mark.parametrize(
@@ -194,5 +195,5 @@ def test_that_json_parser_can_set_all_keys(test_json, key, value, expected_outpu
)
def test_that_json_parser_can_delete_all_keys(test_json, key, expected_output):
parser = JsonParser(json.dumps(test_json))
- parser.delete(key, delete_all=True)
+ parser.delete(key, all=True)
assert parser.stringify() == json.dumps(expected_output)