Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Add custom coverage test
Browse files Browse the repository at this point in the history
  • Loading branch information
YasinKaryagdi committed Jun 13, 2024
1 parent de2f99c commit c8f9434
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from collections import deque
import datetime
import socket
from cov import test, mark

import aiohttp

Expand Down Expand Up @@ -103,15 +104,17 @@
Response = Coroutine[Any, Any, T]


@test(2)
async def json_or_text(response: aiohttp.ClientResponse) -> Union[Dict[str, Any], str]:
text = await response.text(encoding='utf-8')
try:
if response.headers['content-type'] == 'application/json':
mark(0)
return utils._from_json(text)
except KeyError:
# Thanks Cloudflare
pass

mark(1)
return text


Expand Down

0 comments on commit c8f9434

Please sign in to comment.