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_abstract_parser.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/test_abstract_parser.py (limited to 'tests/test_abstract_parser.py') diff --git a/tests/test_abstract_parser.py b/tests/test_abstract_parser.py new file mode 100644 index 0000000..e69de29 -- 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_abstract_parser.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/test_abstract_parser.py (limited to 'tests/test_abstract_parser.py') diff --git a/tests/test_abstract_parser.py b/tests/test_abstract_parser.py deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.3 From 36b8e0f288883284e2677f7873088c5a2d779d79 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Wed, 5 Aug 2020 21:12:38 -0500 Subject: Add tests for abstract parser --- tests/test_abstract_parser.py | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/test_abstract_parser.py (limited to 'tests/test_abstract_parser.py') diff --git a/tests/test_abstract_parser.py b/tests/test_abstract_parser.py new file mode 100644 index 0000000..d1cc4ef --- /dev/null +++ b/tests/test_abstract_parser.py @@ -0,0 +1,50 @@ +import pytest + +from config_file import AbstractParser + + +class ConcreteParser(AbstractParser): + def __init__(self, file_contents): + super().__init__(file_contents) + + def get(self, key): + super().get(key) + + def set(self, key, value): + super().set(key, value) + + def delete(self, section_key): + super().delete(section_key) + + def has(self, section_key: str): + super().has(section_key) + + def stringify(self): + super().stringify() + + def reset_internal_contents(self, file_contents: str) -> None: + super().reset_internal_contents(file_contents) + + +def test_that_abstract_parser_can_not_be_instantiated(): + with pytest.raises(TypeError): + AbstractParser("") + + +@pytest.mark.parametrize( + "function, args", + [ + (ConcreteParser("").get, ("",)), + (ConcreteParser("").set, ("", "")), + (ConcreteParser("").delete, ("",)), + (ConcreteParser("").stringify, None), + (ConcreteParser("").has, ("",)), + (ConcreteParser("").reset_internal_contents, ("",)), + ], +) +def test_that_abstract_parser_raises_not_implemented_errors(function, args): + with pytest.raises(NotImplementedError): + if args is None: + function() + else: + function(*args) -- cgit v1.2.3 From a933dc9c424e68b1773d8af3140c7d60422b428b Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Wed, 5 Aug 2020 21:28:44 -0500 Subject: Fix AbstractParser imports for tests --- tests/test_abstract_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_abstract_parser.py') diff --git a/tests/test_abstract_parser.py b/tests/test_abstract_parser.py index d1cc4ef..890b173 100644 --- a/tests/test_abstract_parser.py +++ b/tests/test_abstract_parser.py @@ -1,6 +1,6 @@ import pytest -from config_file import AbstractParser +from config_file.abstract_parser import AbstractParser class ConcreteParser(AbstractParser): -- cgit v1.2.3 From 4baf3f13f6bd1a4a21b249969b3b311948568cbb Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Wed, 5 Aug 2020 21:38:37 -0500 Subject: Add docstrings to AbstractParser tests --- tests/test_abstract_parser.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/test_abstract_parser.py') diff --git a/tests/test_abstract_parser.py b/tests/test_abstract_parser.py index 890b173..a2d9dbe 100644 --- a/tests/test_abstract_parser.py +++ b/tests/test_abstract_parser.py @@ -4,6 +4,12 @@ from config_file.abstract_parser import AbstractParser class ConcreteParser(AbstractParser): + """ + ConcreteParser is a concrete implementation of the + AbstractParser that just calls the AbstractParser's + methods so we can ensure they raise a NotImplementedError. + """ + def __init__(self, file_contents): super().__init__(file_contents) @@ -27,6 +33,12 @@ class ConcreteParser(AbstractParser): def test_that_abstract_parser_can_not_be_instantiated(): + """ + config_file.abstract_parser.abstract_parser + + Ensure the AbstractParser raises a TypeError when it is + instantiated. + """ with pytest.raises(TypeError): AbstractParser("") @@ -43,6 +55,12 @@ def test_that_abstract_parser_can_not_be_instantiated(): ], ) def test_that_abstract_parser_raises_not_implemented_errors(function, args): + """ + config_file.abstract_parser.abstract_parser + + Ensure the AbstractParser raises a NotImplementedError + for every method in it. + """ with pytest.raises(NotImplementedError): if args is None: function() -- 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_abstract_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_abstract_parser.py') diff --git a/tests/test_abstract_parser.py b/tests/test_abstract_parser.py index a2d9dbe..1816f6b 100644 --- a/tests/test_abstract_parser.py +++ b/tests/test_abstract_parser.py @@ -34,7 +34,7 @@ class ConcreteParser(AbstractParser): def test_that_abstract_parser_can_not_be_instantiated(): """ - config_file.abstract_parser.abstract_parser + config_file.abstract_parser.AbstractParser Ensure the AbstractParser raises a TypeError when it is instantiated. @@ -56,7 +56,7 @@ def test_that_abstract_parser_can_not_be_instantiated(): ) def test_that_abstract_parser_raises_not_implemented_errors(function, args): """ - config_file.abstract_parser.abstract_parser + config_file.abstract_parser.AbstractParser Ensure the AbstractParser raises a NotImplementedError for every method in it. -- cgit v1.2.3 From ee37bd79de456c4e55a2e68f2f9062b1d01ab035 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Fri, 7 Aug 2020 19:40:02 -0500 Subject: Conform test abstract parser has syntax --- tests/test_abstract_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_abstract_parser.py') diff --git a/tests/test_abstract_parser.py b/tests/test_abstract_parser.py index 1816f6b..0012127 100644 --- a/tests/test_abstract_parser.py +++ b/tests/test_abstract_parser.py @@ -22,7 +22,7 @@ class ConcreteParser(AbstractParser): def delete(self, section_key): super().delete(section_key) - def has(self, section_key: str): + def has(self, section_key: str, wild: bool = False): super().has(section_key) def stringify(self): -- cgit v1.2.3