Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pytest-api-cov"
version = "1.2.1"
version = "1.2.2"
description = "Pytest Plugin to provide API Coverage statistics for Python Web Frameworks"
readme = "README.md"
authors = [{ name = "Barnaby Gill", email = "barnabasgill@gmail.com" }]
Expand Down
11 changes: 8 additions & 3 deletions src/pytest_api_cov/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ def _extract_path_and_method(self, name: str, args: Any, kwargs: Any) -> Optiona
first = args[0]
if isinstance(first, str):
path = first.partition("?")[0]
method = name.upper()
method = kwargs.get("method", name).upper()
if method == "OPEN":
method = "GET"

return path, method

# For starlette/requests TestClient, args[0] may be a Request or PreparedRequest
Expand All @@ -259,19 +262,21 @@ def _extract_path_and_method(self, name: str, args: Any, kwargs: Any) -> Optiona
else:
return path, method

# Try kwargs-based FlaskClient open signature
if kwargs:
path_kw = kwargs.get("path") or kwargs.get("url") or kwargs.get("uri")
if isinstance(path_kw, str):
path = path_kw.partition("?")[0]
method = kwargs.get("method", name).upper()
if method == "OPEN":
method = "GET"

return path, method

return None

def __getattr__(self, name: str) -> Any:
attr = getattr(self._wrapped, name)
if name in ["get", "post", "put", "delete", "patch", "head", "options"]:
if name in {"get", "post", "put", "delete", "patch", "head", "options"}:

def tracked_method(*args: Any, **kwargs: Any) -> Any:
response = attr(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading