* [Buildroot] [PATCH 1/1] support/testing: add python-httpx2 runtime test
@ 2026-10-12 2:05 James Hilliard
2026-10-13 8:06 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 2+ messages in thread
From: James Hilliard @ 2026-10-12 2:05 UTC (permalink / raw)
To: buildroot; +Cc: James Hilliard
Exercise synchronous and asynchronous HTTP requests with python-httpx2
against a local HTTP server, checking the response status and JSON body.
This covers the httpcore2 socket transports and the AnyIO asyncio backend
used by the asynchronous client.
Bind the server to an ephemeral loopback port so the test does not depend
on external services, and shut it down when the sample finishes.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
.../tests/package/sample_python_httpx2.py | 37 +++++++++++++++++++
.../tests/package/test_python_httpx2.py | 12 ++++++
2 files changed, 49 insertions(+)
create mode 100644 support/testing/tests/package/sample_python_httpx2.py
create mode 100644 support/testing/tests/package/test_python_httpx2.py
diff --git a/support/testing/tests/package/sample_python_httpx2.py b/support/testing/tests/package/sample_python_httpx2.py
new file mode 100644
index 0000000000..645ceb97f8
--- /dev/null
+++ b/support/testing/tests/package/sample_python_httpx2.py
@@ -0,0 +1,37 @@
+import asyncio
+from http.server import BaseHTTPRequestHandler, HTTPServer
+from threading import Thread
+
+import httpx2
+
+
+class RequestHandler(BaseHTTPRequestHandler):
+ def do_GET(self):
+ body = b'{"message": "Hello, Buildroot!"}'
+ self.send_response(200)
+ self.send_header("Content-Type", "application/json")
+ self.send_header("Content-Length", str(len(body)))
+ self.end_headers()
+ self.wfile.write(body)
+
+
+async def test_async(url):
+ async with httpx2.AsyncClient(trust_env=False) as client:
+ response = await client.get(url)
+ assert response.status_code == 200
+ assert response.json() == {"message": "Hello, Buildroot!"}
+
+
+with HTTPServer(("127.0.0.1", 0), RequestHandler) as server:
+ thread = Thread(target=server.serve_forever)
+ thread.start()
+ try:
+ url = f"http://127.0.0.1:{server.server_port}/"
+ with httpx2.Client(trust_env=False) as client:
+ response = client.get(url)
+ assert response.status_code == 200
+ assert response.json() == {"message": "Hello, Buildroot!"}
+ asyncio.run(test_async(url))
+ finally:
+ server.shutdown()
+ thread.join()
diff --git a/support/testing/tests/package/test_python_httpx2.py b/support/testing/tests/package/test_python_httpx2.py
new file mode 100644
index 0000000000..d3865ea8f2
--- /dev/null
+++ b/support/testing/tests/package/test_python_httpx2.py
@@ -0,0 +1,12 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3Httpx2(TestPythonPackageBase):
+ __test__ = True
+ config = TestPythonPackageBase.config + \
+ """
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_PYTHON_HTTPX2=y
+ """
+ sample_scripts = ["tests/package/sample_python_httpx2.py"]
+ timeout = 30
--
2.53.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [Buildroot] [PATCH 1/1] support/testing: add python-httpx2 runtime test
2026-10-12 2:05 [Buildroot] [PATCH 1/1] support/testing: add python-httpx2 runtime test James Hilliard
@ 2026-10-13 8:06 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-13 8:06 UTC (permalink / raw)
To: James Hilliard; +Cc: buildroot
On Sun, Oct 11, 2026 at 08:05:36PM -0600, James Hilliard wrote:
> Exercise synchronous and asynchronous HTTP requests with python-httpx2
> against a local HTTP server, checking the response status and JSON body.
> This covers the httpcore2 socket transports and the AnyIO asyncio backend
> used by the asynchronous client.
>
> Bind the server to an ephemeral loopback port so the test does not depend
> on external services, and shut it down when the sample finishes.
>
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Thanks for this test! You had forgotten to update the DEVELOPERS file,
so I did that and applied. Thanks a lot!
Best regards,
Thomas Petazzoni
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-13 17:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-12 2:05 [Buildroot] [PATCH 1/1] support/testing: add python-httpx2 runtime test James Hilliard
2026-10-13 8:06 ` Thomas Petazzoni via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox