Skip to content

Commit c180fac

Browse files
committed
test(oauth): mark invariant branches for coverage
1 parent b3273d0 commit c180fac

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/mcp/client/auth/oauth2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.
666666
# Retry with new tokens
667667
self._add_auth_header(request)
668668
retry_after_authorization = True
669-
elif response.status_code == 403:
669+
elif response.status_code == 403: # pragma: no branch
670670
# Step 1: Extract error field from WWW-Authenticate header
671671
error = extract_field_from_www_auth(response, "error")
672672

@@ -690,5 +690,5 @@ async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.
690690
retry_after_authorization = True
691691

692692
# The retried resource request can itself be a session-long GET.
693-
if retry_after_authorization:
693+
if retry_after_authorization: # pragma: no branch
694694
yield request

tests/client/test_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,7 +2413,7 @@ async def complete_request() -> None:
24132413
async with anyio.create_task_group() as task_group:
24142414
async with oauth_provider.context.flow_lock:
24152415
task_group.start_soon(complete_request)
2416-
with anyio.fail_after(5):
2416+
with anyio.fail_after(5): # pragma: no branch
24172417
await completed.wait()
24182418

24192419

@@ -2441,7 +2441,7 @@ async def drive_403() -> None:
24412441
while oauth_provider.context.flow_lock.statistics().tasks_waiting == 0:
24422442
await anyio.sleep(0)
24432443

2444-
async with oauth_provider.context.lock:
2444+
async with oauth_provider.context.lock: # pragma: no branch
24452445
oauth_provider.context.current_tokens = OAuthToken(
24462446
access_token="new_access_token",
24472447
token_type="Bearer",

0 commit comments

Comments
 (0)