Skip to content

Commit 1a2a423

Browse files
committed
Python: Refactor httpx tests
and improve QLDocs a bit
1 parent f72a1d9 commit 1a2a423

File tree

2 files changed

+14
-8
lines changed
  • python/ql

2 files changed

+14
-8
lines changed

python/ql/lib/semmle/python/frameworks/Httpx.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ private import semmle.python.ApiGraphs
1818
* - https://www.python-httpx.org/
1919
*/
2020
private module HttpxModel {
21+
/**
22+
* An outgoing HTTP request, from the `httpx` library.
23+
*
24+
* See https://www.python-httpx.org/api/
25+
*/
2126
private class RequestCall extends HTTP::Client::Request::Range, DataFlow::CallCfgNode {
2227
string methodName;
2328

@@ -47,7 +52,7 @@ private module HttpxModel {
4752
/**
4853
* Provides models for the `httpx.[Async]Client` class
4954
*
50-
* See https://www.python-httpx.org/async/
55+
* See https://www.python-httpx.org/api/#client
5156
*/
5257
module Client {
5358
/** Get a reference to the `httpx.Client` or `httpx.AsyncClient` class. */

python/ql/test/library-tests/frameworks/httpx/test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
response = client.request("method", url="url") # $ clientRequestUrlPart="url"
1616
response = client.stream("method", url="url") # $ clientRequestUrlPart="url"
1717

18-
client = httpx.AsyncClient()
19-
response = client.get("url") # $ clientRequestUrlPart="url"
20-
response = client.post("url") # $ clientRequestUrlPart="url"
21-
response = client.patch("url") # $ clientRequestUrlPart="url"
22-
response = client.options("url") # $ clientRequestUrlPart="url"
23-
response = client.request("method", url="url") # $ clientRequestUrlPart="url"
24-
response = client.stream("method", url="url") # $ clientRequestUrlPart="url"
18+
async def async_test():
19+
client = httpx.AsyncClient()
20+
response = await client.get("url") # $ clientRequestUrlPart="url"
21+
response = await client.post("url") # $ clientRequestUrlPart="url"
22+
response = await client.patch("url") # $ clientRequestUrlPart="url"
23+
response = await client.options("url") # $ clientRequestUrlPart="url"
24+
response = await client.request("method", url="url") # $ clientRequestUrlPart="url"
25+
response = await client.stream("method", url="url") # $ clientRequestUrlPart="url"

0 commit comments

Comments
 (0)