From aa44fe7a60a4f3326cc47877b3e246b56d46d6ac Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 20 Jun 2020 13:41:35 -0500 Subject: 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. --- tests/test_ini_parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/test_ini_parser.py') 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 }"]) -- cgit v1.2.3 From b3fb6aae1201faca1238b3c79e5e95ba57282bf1 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 20 Jun 2020 15:35:05 -0500 Subject: Add more type hints to ConfigFile and lint all files --- tests/test_ini_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_ini_parser.py') diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py index 1b2fd3b..fb92373 100644 --- a/tests/test_ini_parser.py +++ b/tests/test_ini_parser.py @@ -1,7 +1,7 @@ import pytest -from config_file.parsers.ini_parser import IniParser from config_file.exceptions import ParsingError +from config_file.parsers.ini_parser import IniParser @pytest.mark.parametrize("ini_file", ["blahblahblah", "{ 'key1': 5 }"]) -- cgit v1.2.3 From 2d6b50509cc29516f9ef379619d9a3ac15c5c629 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 11 Jul 2020 14:56:53 -0500 Subject: Fix imports in tests/ --- tests/test_ini_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_ini_parser.py') diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py index fb92373..d39758e 100644 --- a/tests/test_ini_parser.py +++ b/tests/test_ini_parser.py @@ -1,7 +1,7 @@ import pytest from config_file.exceptions import ParsingError -from config_file.parsers.ini_parser import IniParser +from config_file.parsers import IniParser @pytest.mark.parametrize("ini_file", ["blahblahblah", "{ 'key1': 5 }"]) -- cgit v1.2.3 From 3fa782f5b5e3bd4445a5db63c0fce5aaac2d4ac3 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Mon, 20 Jul 2020 22:55:40 -0500 Subject: Add work in progress tests --- tests/test_ini_parser.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'tests/test_ini_parser.py') diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py index d39758e..6577291 100644 --- a/tests/test_ini_parser.py +++ b/tests/test_ini_parser.py @@ -1,7 +1,7 @@ import pytest from config_file.exceptions import ParsingError -from config_file.parsers import IniParser +from config_file.parsers.ini_parser import IniParser @pytest.mark.parametrize("ini_file", ["blahblahblah", "{ 'key1': 5 }"]) @@ -11,29 +11,19 @@ def test_incorrect_ini_formats(ini_file): @pytest.mark.parametrize( - "section_key,expected_value,parse_type", + "section_key,expected_value", [ - ("test_section.intkey", 5, True), - ("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), - ("test_section.floatkey", "5.3", False), + ("test_section.intkey", "5"), + ("test_section.strkey", "blah"), + ("test_section.boolkey", "false"), + ("test_section.floatkey", "5.3"), ( "test_section", {"intkey": "5", "strkey": "blah", "boolkey": "false", "floatkey": "5.3"}, - False, - ), - ( - "test_section", - {"intkey": 5, "strkey": "blah", "boolkey": False, "floatkey": 5.3}, - True, ), ], ) -def test_that_ini_parser_can_get_values(section_key, expected_value, parse_type): +def test_that_ini_parser_can_get_values(section_key, expected_value): ini_file = """[test_section] intkey = 5 strkey = blah @@ -42,7 +32,7 @@ floatkey = 5.3 """ parser = IniParser(ini_file) - assert parser.get(section_key, parse_types=parse_type) == expected_value + assert parser.get(section_key) == expected_value @pytest.mark.parametrize( -- cgit v1.2.3 From df90fd036d004c79f340e4c1d01b2171add80047 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Wed, 29 Jul 2020 21:27:18 -0500 Subject: Fix tests for recent changes --- tests/test_ini_parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/test_ini_parser.py') diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py index 6577291..45e82c3 100644 --- a/tests/test_ini_parser.py +++ b/tests/test_ini_parser.py @@ -1,6 +1,6 @@ import pytest -from config_file.exceptions import ParsingError +from config_file.exceptions import ParsingError, MissingKeyError from config_file.parsers.ini_parser import IniParser @@ -81,10 +81,10 @@ 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"], ) -def test_that_ini_parser_delete_raises_value_errors(section_key): +def test_that_ini_parser_delete_raises_missing_key_errors(section_key): ini_file = """[test_section]\nkey1 = value\n\n""" parser = IniParser(ini_file) - with pytest.raises(ValueError): + with pytest.raises(MissingKeyError): parser.delete(section_key) -- cgit v1.2.3 From b1c23487c33fc2ad5503b6340b17980a326918c8 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 1 Aug 2020 11:53:56 -0500 Subject: Lint files --- tests/test_ini_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_ini_parser.py') diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py index 45e82c3..46966c9 100644 --- a/tests/test_ini_parser.py +++ b/tests/test_ini_parser.py @@ -1,6 +1,6 @@ import pytest -from config_file.exceptions import ParsingError, MissingKeyError +from config_file.exceptions import MissingKeyError, ParsingError from config_file.parsers.ini_parser import IniParser -- cgit v1.2.3 From 59eeb1321fbad41dce7c971778e37ac1943fda3b Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Wed, 5 Aug 2020 20:39:28 -0500 Subject: Redo package to have a flat package structure By having a flat package structure like this, it'll avoid exposing packages and things we don't want to be exposed. --- tests/test_ini_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_ini_parser.py') diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py index 46966c9..24507b7 100644 --- a/tests/test_ini_parser.py +++ b/tests/test_ini_parser.py @@ -1,7 +1,7 @@ import pytest from config_file.exceptions import MissingKeyError, ParsingError -from config_file.parsers.ini_parser import IniParser +from config_file.ini_parser import IniParser @pytest.mark.parametrize("ini_file", ["blahblahblah", "{ 'key1': 5 }"]) @@ -39,7 +39,7 @@ floatkey = 5.3 "test_input", ["invalid.invalid_key"], ) def test_that_getting_unknown_sections_or_keys_throws_errors(test_input): - with pytest.raises(ParsingError): + with pytest.raises(KeyError): IniParser("").get(test_input) -- cgit v1.2.3 From 836cefe45633331d0e5692295174bf3181a5e365 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Thu, 6 Aug 2020 09:47:35 -0500 Subject: Change MissingKeyErrors to KeyError --- tests/test_ini_parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/test_ini_parser.py') diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py index 24507b7..2accc8f 100644 --- a/tests/test_ini_parser.py +++ b/tests/test_ini_parser.py @@ -1,6 +1,6 @@ import pytest -from config_file.exceptions import MissingKeyError, ParsingError +from config_file.exceptions import ParsingError from config_file.ini_parser import IniParser @@ -81,10 +81,10 @@ 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"], ) -def test_that_ini_parser_delete_raises_missing_key_errors(section_key): +def test_that_ini_parser_delete_raises_key_error(section_key): ini_file = """[test_section]\nkey1 = value\n\n""" parser = IniParser(ini_file) - with pytest.raises(MissingKeyError): + with pytest.raises(KeyError): parser.delete(section_key) -- cgit v1.2.3 From 286cec0d1c05b6b85f49714ec4635d2e8dcacfc7 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Thu, 6 Aug 2020 19:03:53 -0500 Subject: Remove ini and json parser tests They heavily overlap with the config_file test case now and are unnecessary. --- tests/test_ini_parser.py | 97 ------------------------------------------------ 1 file changed, 97 deletions(-) delete mode 100644 tests/test_ini_parser.py (limited to 'tests/test_ini_parser.py') diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py deleted file mode 100644 index 2accc8f..0000000 --- a/tests/test_ini_parser.py +++ /dev/null @@ -1,97 +0,0 @@ -import pytest - -from config_file.exceptions import ParsingError -from config_file.ini_parser import IniParser - - -@pytest.mark.parametrize("ini_file", ["blahblahblah", "{ 'key1': 5 }"]) -def test_incorrect_ini_formats(ini_file): - with pytest.raises(ParsingError): - IniParser(ini_file) - - -@pytest.mark.parametrize( - "section_key,expected_value", - [ - ("test_section.intkey", "5"), - ("test_section.strkey", "blah"), - ("test_section.boolkey", "false"), - ("test_section.floatkey", "5.3"), - ( - "test_section", - {"intkey": "5", "strkey": "blah", "boolkey": "false", "floatkey": "5.3"}, - ), - ], -) -def test_that_ini_parser_can_get_values(section_key, expected_value): - ini_file = """[test_section] -intkey = 5 -strkey = blah -boolkey = false -floatkey = 5.3 - -""" - parser = IniParser(ini_file) - assert parser.get(section_key) == expected_value - - -@pytest.mark.parametrize( - "test_input", ["invalid.invalid_key"], -) -def test_that_getting_unknown_sections_or_keys_throws_errors(test_input): - with pytest.raises(KeyError): - IniParser("").get(test_input) - - -@pytest.mark.parametrize( - "section_key,value,expected_value", - [ - ("test.key1", "different value", "[test]\nkey1 = different value\n\n"), - ("test.key2", 5, "[test]\nkey1 = value1\nkey2 = 5\n\n"), - ("test2.key", False, "[test]\nkey1 = value1\n\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""" - parser = IniParser(ini_file) - parser.set(section_key, value) - assert parser.stringify() == expected_value - - -@pytest.mark.parametrize( - "ini_file", - ["[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) - assert parser.stringify() == ini_file - - -@pytest.mark.parametrize( - "section_key,expected_result", - [("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""" - parser = IniParser(ini_file) - parser.delete(section_key) - assert parser.stringify() == expected_result - - -@pytest.mark.parametrize( - "section_key", ["section_is_not_present", "test_section.but_key_is_not_present"], -) -def test_that_ini_parser_delete_raises_key_error(section_key): - ini_file = """[test_section]\nkey1 = value\n\n""" - parser = IniParser(ini_file) - with pytest.raises(KeyError): - parser.delete(section_key) - - -@pytest.mark.parametrize( - "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""" - parser = IniParser(ini_file) - assert parser.has(section_key) -- cgit v1.2.3