diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2025-08-16 09:57:46 -0400 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2025-08-16 09:57:46 -0400 |
| commit | 3b796ff25876e84c636baea33329bd3c43867de6 (patch) | |
| tree | 8284474d4002817760965c480b022aa43eac778d /tests | |
| parent | Drop support for python 3.6, 3.7, and 3.8 (diff) | |
| download | config-file-3b796ff25876e84c636baea33329bd3c43867de6.zip | |
Update dependencies and linting
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/conftest.py | 2 | ||||
| -rw-r--r-- | tests/test_abstract_parser.py | 37 |
2 files changed, 23 insertions, 16 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 81f2c0b..18c77e4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -89,7 +89,7 @@ def template_original_file() -> Callable[[Path], Path]: @pytest.fixture def template_and_parser( - template_file: Callable[[str, str], Path] + template_file: Callable[[str, str], Path], ) -> Callable[[str, str], Tuple[Path, AbstractParser]]: """ Retrieve the parser and test template for a particular 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 |