diff --git a/pyproject.toml b/pyproject.toml index deaeba6..fa70667 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,3 @@ pytest11 = {pytest_tiny_api_client = "pytest_tiny_api_client"} [tool.isort] length_sort = true - -[tool.flake8] -ignore = ['E731'] -max-line-length = 88 diff --git a/pytest_tiny_api_client.py b/pytest_tiny_api_client.py index 24fdd45..f4b7887 100644 --- a/pytest_tiny_api_client.py +++ b/pytest_tiny_api_client.py @@ -16,23 +16,28 @@ # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301 USA import pytest from unittest import mock from typing import Any -from collections.abc import Generator +from collections.abc import Generator, Callable -def _api_call(endpoint: str, **kwargs) -> Any: +def _api_call(endpoint: str, **kwargs: Any) -> Any: """Placeholder function to patch when testing""" return None # Patch the method decorators with a call to `_api_call` -_method = lambda route, **k: lambda fn: lambda self: fn(self, _api_call(route, **k)) +def _method(route: str, **k: Any) -> Callable[[Callable], Callable]: + return lambda fn: lambda self, *args, **_: fn( + self, _api_call(route, **k), *args + ) + mock.patch('tiny_api_client.get', _method).start() mock.patch('tiny_api_client.post', _method).start() @@ -41,7 +46,7 @@ def _api_call(endpoint: str, **kwargs) -> Any: mock.patch('tiny_api_client.delete', _method).start() -def pytest_sessionfinish(session, exitstatus): +def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None: mock.patch.stopall()