Skip to content

Commit 3b7099e

Browse files
authored
Merge pull request #13 from BarnabasG/initial
1.2.2 Fixing flask testclient.open logic
2 parents e18f232 + ccdea5d commit 3b7099e

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pytest-api-cov"
3-
version = "1.2.1"
3+
version = "1.2.2"
44
description = "Pytest Plugin to provide API Coverage statistics for Python Web Frameworks"
55
readme = "README.md"
66
authors = [{ name = "Barnaby Gill", email = "barnabasgill@gmail.com" }]

src/pytest_api_cov/plugin.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ def _extract_path_and_method(self, name: str, args: Any, kwargs: Any) -> Optiona
246246
first = args[0]
247247
if isinstance(first, str):
248248
path = first.partition("?")[0]
249-
method = name.upper()
249+
method = kwargs.get("method", name).upper()
250+
if method == "OPEN":
251+
method = "GET"
252+
250253
return path, method
251254

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

262-
# Try kwargs-based FlaskClient open signature
263265
if kwargs:
264266
path_kw = kwargs.get("path") or kwargs.get("url") or kwargs.get("uri")
265267
if isinstance(path_kw, str):
266268
path = path_kw.partition("?")[0]
267269
method = kwargs.get("method", name).upper()
270+
if method == "OPEN":
271+
method = "GET"
272+
268273
return path, method
269274

270275
return None
271276

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

276281
def tracked_method(*args: Any, **kwargs: Any) -> Any:
277282
response = attr(*args, **kwargs)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)