aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_ini_parser.py
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2020-01-17 16:10:39 -0600
committerEugene Triguba <eugenetriguba@gmail.com>2020-01-17 16:10:39 -0600
commit993f92f03626adf583d8cedb01f52b18afe28c29 (patch)
tree2ddef347ea4f13e5642da5f64ccb648cc7b64913 /tests/test_ini_parser.py
parentBump version: 0.2.0 → 0.3.0 (diff)
downloadconfig-file-993f92f03626adf583d8cedb01f52b18afe28c29.zip
Run pre-commit on all files
Diffstat (limited to 'tests/test_ini_parser.py')
-rw-r--r--tests/test_ini_parser.py42
1 files changed, 13 insertions, 29 deletions
diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py
index 6e5b0a8..5c26b23 100644
--- a/tests/test_ini_parser.py
+++ b/tests/test_ini_parser.py
@@ -3,13 +3,7 @@ import pytest
from config_file.parsers.ini_parser import IniParser, ParsingError
-@pytest.mark.parametrize(
- "ini_file",
- [
- "blahblahblah",
- "{ 'key1': 5 }",
- ]
-)
+@pytest.mark.parametrize("ini_file", ["blahblahblah", "{ 'key1': 5 }"])
def test_incorrect_ini_formats(ini_file):
with pytest.raises(ParsingError):
IniParser(ini_file)
@@ -22,7 +16,6 @@ def test_incorrect_ini_formats(ini_file):
("test_section.strkey", "blah", True),
("test_section.boolkey", False, True),
("test_section.floatkey", 5.3, True),
-
("test_section.intkey", "5", False),
("test_section.strkey", "blah", False),
("test_section.boolkey", "false", False),
@@ -30,7 +23,13 @@ def test_incorrect_ini_formats(ini_file):
],
)
def test_that_ini_parser_can_get_values(section_key, expected_value, parse_type):
- ini_file = """[test_section]\nintkey = 5\nstrkey = blah\nboolkey = false\nfloatkey = 5.3\n\n"""
+ ini_file = """[test_section]
+intkey = 5
+strkey = blah
+boolkey = false
+floatkey = 5.3
+
+"""
parser = IniParser(ini_file)
assert parser.get(section_key, parse_type=parse_type) == expected_value
@@ -41,7 +40,7 @@ def test_that_ini_parser_can_get_values(section_key, expected_value, parse_type)
("test.key1", "different value", "[test]\nkey1 = different value\n\n"),
("test.key2", 5, "[test]\nkey1 = different value\nkey2 = 5\n\n"),
("test2.key", False, "[test]\nkey1 = value1\n[test2]\nkey = False\n\n"),
- ]
+ ],
)
def test_that_ini_parser_can_set_values(section_key, value, expected_value):
ini_file = """[test]\nkey1 = value1\n\n"""
@@ -51,11 +50,7 @@ def test_that_ini_parser_can_set_values(section_key, value, expected_value):
@pytest.mark.parametrize(
"ini_file",
- [
- "[test]\nkey1 = value1\n\n",
- "[test]\nblah = 5\n\n[section2]\nkey = 2\n\n",
- "",
- ]
+ ["[test]\nkey1 = value1\n\n", "[test]\nblah = 5\n\n[section2]\nkey = 2\n\n", ""],
)
def test_that_ini_parser_can_be_stringified(ini_file):
parser = IniParser(ini_file)
@@ -64,10 +59,7 @@ def test_that_ini_parser_can_be_stringified(ini_file):
@pytest.mark.parametrize(
"section_key,expected_result",
- [
- ("test_section", ""),
- ("test_section.key1", "[test_section]\n\n"),
- ],
+ [("test_section", ""), ("test_section.key1", "[test_section]\n\n")],
)
def test_that_ini_parser_can_delete(section_key, expected_result):
ini_file = """[test_section]\nkey1 = value\n\n"""
@@ -77,11 +69,7 @@ def test_that_ini_parser_can_delete(section_key, expected_result):
@pytest.mark.parametrize(
- "section_key",
- [
- "section_is_not_present",
- "test_section.but_key_is_not_present",
- ],
+ "section_key", ["section_is_not_present", "test_section.but_key_is_not_present"],
)
def test_that_ini_parser_delete_raises_value_errors(section_key):
ini_file = """[test_section]\nkey1 = value\n\n"""
@@ -91,11 +79,7 @@ def test_that_ini_parser_delete_raises_value_errors(section_key):
@pytest.mark.parametrize(
- "section_key",
- [
- "test_section",
- "test_section.key1",
- ],
+ "section_key", ["test_section", "test_section.key1"],
)
def test_that_ini_parser_can_check_its_section_and_keys(section_key):
ini_file = """[test_section]\nkey1 = value\n\n"""