aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_abstract_parser.py
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2025-08-16 09:57:46 -0400
committerEugene Triguba <hello@eugenetriguba.com>2025-08-16 09:57:46 -0400
commit3b796ff25876e84c636baea33329bd3c43867de6 (patch)
tree8284474d4002817760965c480b022aa43eac778d /tests/test_abstract_parser.py
parentDrop support for python 3.6, 3.7, and 3.8 (diff)
downloadconfig-file-3b796ff25876e84c636baea33329bd3c43867de6.zip
Update dependencies and linting
Diffstat (limited to 'tests/test_abstract_parser.py')
-rw-r--r--tests/test_abstract_parser.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/tests/test_abstract_parser.py b/tests/test_abstract_parser.py
index a74d753..7d6e1fd 100644
--- a/tests/test_abstract_parser.py
+++ b/tests/test_abstract_parser.py
@@ -1,3 +1,5 @@
+from typing import Any
+
import pytest
from config_file.parsers.abstract_parser import AbstractParser
@@ -14,26 +16,27 @@ class ConcreteAbstractParser(AbstractParser):
def __init__(self, file_contents):
super().__init__(file_contents)
- def get(self, key):
- super().get(key)
+ def get(self, key: str) -> Any:
+ super().get(key) # type: ignore
- def set(self, key, value):
- super().set(key, value)
+ def set(self, key: str, value: Any) -> None:
+ super().set(key, value) # type: ignore
- def delete(self, section_key):
- super().delete(section_key)
+ def delete(self, key: str) -> None:
+ super().delete(key) # type: ignore
- def has(self, section_key: str, wild: bool = False):
- super().has(section_key)
+ def has(self, key: str, wild: bool = False) -> bool:
+ return super().has(key, wild=wild) # type: ignore
- def __str__(self):
- super().__str__()
+ def __str__(self) -> str:
+ return super().__str__() # type: ignore
def reset_internal_contents(self, file_contents: str) -> None:
- super().reset_internal_contents(file_contents)
+ super().reset_internal_contents(file_contents) # type: ignore
+ @property
def parsed_content(self) -> dict:
- super().parsed_content()
+ return super().parsed_content() # type: ignore
def test_that_abstract_parser_can_not_be_instantiated():
@@ -44,7 +47,7 @@ def test_that_abstract_parser_can_not_be_instantiated():
instantiated.
"""
with pytest.raises(TypeError):
- AbstractParser("")
+ AbstractParser("") # type: ignore
def test_that_base_parser_can_not_be_instantiated():
@@ -55,7 +58,7 @@ def test_that_base_parser_can_not_be_instantiated():
instantiated.
"""
with pytest.raises(TypeError):
- BaseParser("")
+ BaseParser("") # type: ignore
@pytest.mark.parametrize(
@@ -67,7 +70,6 @@ def test_that_base_parser_can_not_be_instantiated():
(ConcreteAbstractParser("").__str__, None),
(ConcreteAbstractParser("").has, ("",)),
(ConcreteAbstractParser("").reset_internal_contents, ("",)),
- (ConcreteAbstractParser("").parsed_content, None),
],
)
def test_that_abstract_and_base_parser_raises_not_implemented_errors(function, args):
@@ -83,3 +85,8 @@ def test_that_abstract_and_base_parser_raises_not_implemented_errors(function, a
function()
else:
function(*args)
+
+
+def test_parsed_content_raises_not_implemented_error():
+ with pytest.raises(NotImplementedError):
+ ConcreteAbstractParser("").parsed_content