From: James Hilliard <james.hilliard1@gmail.com>
To: buildroot@buildroot.org
Cc: James Hilliard <james.hilliard1@gmail.com>
Subject: [Buildroot] [PATCH 1/1] support/testing: add python-httpx2 runtime test
Date: Sun, 11 Oct 2026 20:05:36 -0600 [thread overview]
Message-ID: <20261012020536.562497-1-james.hilliard1@gmail.com> (raw)
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
next reply other threads:[~2026-10-12 2:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 2:05 James Hilliard [this message]
2026-10-13 8:06 ` [Buildroot] [PATCH 1/1] support/testing: add python-httpx2 runtime test Thomas Petazzoni via buildroot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261012020536.562497-1-james.hilliard1@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=buildroot@buildroot.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox