>>> py3-starlette: Building community/py3-starlette 0.37.2-r1 (using abuild 3.13.0-r3) started Sat, 27 Apr 2024 03:17:04 +0000 >>> py3-starlette: Checking sanity of /home/buildozer/aports/community/py3-starlette/APKBUILD... >>> py3-starlette: Analyzing dependencies... >>> py3-starlette: Installing for build: build-base py3-anyio py3-gpep517 py3-hatchling py3-installer py3-httpx py3-itsdangerous py3-jinja2 py3-pytest-forked py3-pytest-xdist py3-python-multipart py3-trio py3-typing-extensions py3-yaml (1/92) Installing libbz2 (1.0.8-r6) (2/92) Installing libffi (3.4.6-r0) (3/92) Installing gdbm (1.23-r1) (4/92) Installing xz-libs (5.6.1-r3) (5/92) Installing mpdecimal (4.0.0-r0) (6/92) Installing libpanelw (6.4_p20240330-r0) (7/92) Installing readline (8.2.10-r0) (8/92) Installing sqlite-libs (3.45.3-r0) (9/92) Installing python3 (3.12.3-r1) (10/92) Installing python3-pycache-pyc0 (3.12.3-r1) (11/92) Installing pyc (3.12.3-r1) (12/92) Installing py3-idna (3.7-r0) (13/92) Installing py3-idna-pyc (3.7-r0) (14/92) Installing py3-curio (1.6-r2) (15/92) Installing py3-curio-pyc (1.6-r2) (16/92) Installing py3-sniffio (1.3.1-r1) (17/92) Installing py3-sniffio-pyc (1.3.1-r1) (18/92) Installing py3-anyio-pyc (4.3.0-r2) (19/92) Installing python3-pyc (3.12.3-r1) (20/92) Installing py3-anyio (4.3.0-r2) (21/92) Installing py3-installer (0.7.0-r2) (22/92) Installing py3-installer-pyc (0.7.0-r2) (23/92) Installing py3-gpep517 (15-r2) (24/92) Installing py3-gpep517-pyc (15-r2) (25/92) Installing py3-editables (0.5-r2) (26/92) Installing py3-editables-pyc (0.5-r2) (27/92) Installing py3-parsing (3.1.2-r1) (28/92) Installing py3-parsing-pyc (3.1.2-r1) (29/92) Installing py3-packaging (24.0-r1) (30/92) Installing py3-packaging-pyc (24.0-r1) (31/92) Installing py3-pathspec (0.12.1-r2) (32/92) Installing py3-pathspec-pyc (0.12.1-r2) (33/92) Installing py3-pluggy (1.4.0-r1) (34/92) Installing py3-pluggy-pyc (1.4.0-r1) (35/92) Installing py3-trove-classifiers (2024.3.3-r2) (36/92) Installing py3-trove-classifiers-pyc (2024.3.3-r2) (37/92) Installing py3-hatchling (1.24.1-r0) (38/92) Installing py3-hatchling-pyc (1.24.1-r0) (39/92) Installing py3-certifi (2024.2.2-r1) (40/92) Installing py3-certifi-pyc (2024.2.2-r1) (41/92) Installing py3-h11 (0.14.0-r4) (42/92) Installing py3-h11-pyc (0.14.0-r4) (43/92) Installing py3-httpcore (1.0.4-r1) (44/92) Installing py3-httpcore-pyc (1.0.4-r1) (45/92) Installing py3-httpx (0.27.0-r1) (46/92) Installing py3-httpx-pyc (0.27.0-r1) (47/92) Installing py3-itsdangerous (2.1.2-r4) (48/92) Installing py3-itsdangerous-pyc (2.1.2-r4) (49/92) Installing py3-markupsafe (2.1.5-r1) (50/92) Installing py3-markupsafe-pyc (2.1.5-r1) (51/92) Installing py3-jinja2 (3.1.3-r1) (52/92) Installing py3-jinja2-pyc (3.1.3-r1) (53/92) Installing py3-iniconfig (2.0.0-r1) (54/92) Installing py3-iniconfig-pyc (2.0.0-r1) (55/92) Installing py3-py (1.11.0-r3) (56/92) Installing py3-py-pyc (1.11.0-r3) (57/92) Installing py3-pytest (8.1.1-r1) (58/92) Installing py3-pytest-pyc (8.1.1-r1) (59/92) Installing py3-pytest-forked (1.6.0-r2) (60/92) Installing py3-pytest-forked-pyc (1.6.0-r2) (61/92) Installing py3-apipkg (2.1.0-r3) (62/92) Installing py3-apipkg-pyc (2.1.0-r3) (63/92) Installing py3-execnet (1.9.0-r3) (64/92) Installing py3-execnet-pyc (1.9.0-r3) (65/92) Installing py3-pytest-xdist (3.5.0-r1) (66/92) Installing py3-pytest-xdist-pyc (3.5.0-r1) (67/92) Installing py3-python-multipart (0.0.9-r1) (68/92) Installing py3-python-multipart-pyc (0.0.9-r1) (69/92) Installing py3-attrs (23.2.0-r1) (70/92) Installing py3-attrs-pyc (23.2.0-r1) (71/92) Installing py3-async_generator (1.10-r6) (72/92) Installing py3-async_generator-pyc (1.10-r6) (73/92) Installing py3-cparser (2.22-r1) (74/92) Installing py3-cparser-pyc (2.22-r1) (75/92) Installing py3-cffi (1.16.0-r1) (76/92) Installing py3-cffi-pyc (1.16.0-r1) (77/92) Installing py3-cryptography (42.0.5-r1) (78/92) Installing py3-cryptography-pyc (42.0.5-r1) (79/92) Installing py3-openssl (24.1.0-r1) (80/92) Installing py3-openssl-pyc (24.1.0-r1) (81/92) Installing py3-outcome (1.3.0-r1) (82/92) Installing py3-outcome-pyc (1.3.0-r1) (83/92) Installing py3-sortedcontainers (2.4.0-r5) (84/92) Installing py3-sortedcontainers-pyc (2.4.0-r5) (85/92) Installing py3-trio (0.25.0-r1) (86/92) Installing py3-trio-pyc (0.25.0-r1) (87/92) Installing py3-typing-extensions (4.11.0-r1) (88/92) Installing py3-typing-extensions-pyc (4.11.0-r1) (89/92) Installing yaml (0.2.5-r2) (90/92) Installing py3-yaml (6.0.1-r3) (91/92) Installing py3-yaml-pyc (6.0.1-r3) (92/92) Installing .makedepends-py3-starlette (20240427.031707) Executing busybox-1.36.1-r26.trigger OK: 443 MiB in 194 packages >>> py3-starlette: Cleaning up srcdir >>> py3-starlette: Cleaning up pkgdir >>> py3-starlette: Cleaning up tmpdir >>> py3-starlette: Fetching https://distfiles.alpinelinux.org/distfiles/v3.20/py3-starlette-0.37.2.tar.gz Connecting to distfiles.alpinelinux.org (172.105.82.32:443) saving to '/var/cache/distfiles/v3.20/py3-starlette-0.37.2.tar.gz.part' py3-starlette-0.37.2 100% |********************************| 2779k 0:00:00 ETA '/var/cache/distfiles/v3.20/py3-starlette-0.37.2.tar.gz.part' saved >>> py3-starlette: Fetching https://distfiles.alpinelinux.org/distfiles/v3.20/py3-starlette-0.37.2.tar.gz >>> py3-starlette: Checking sha512sums... py3-starlette-0.37.2.tar.gz: OK >>> py3-starlette: Unpacking /var/cache/distfiles/v3.20/py3-starlette-0.37.2.tar.gz... 2024-04-27 03:17:09,230 gpep517 INFO Building wheel via backend hatchling.build 2024-04-27 03:17:09,391 gpep517 INFO The backend produced .dist/starlette-0.37.2-py3-none-any.whl starlette-0.37.2-py3-none-any.whl ============================= test session starts ============================== platform linux -- Python 3.12.3, pytest-8.1.1, pluggy-1.4.0 rootdir: /home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2 configfile: pyproject.toml plugins: xdist-3.5.0, anyio-0.0.0, forked-1.6.0 created: 32/32 workers 32 workers [795 items] ........................................................................ [ 9%] ........................................................................ [ 18%] ........................................................................ [ 27%] ....................................................................x... [ 36%] ........................................................................ [ 45%] ....................................................................x... [ 54%] ........................................................................ [ 63%] ........................................................................ [ 72%] ........................................................................ [ 81%] ........................................................................ [ 90%] ........................................................................ [ 99%] ... [100%] ================================== XFAILURES =================================== ________ test_contextvars[trio-CustomMiddlewareUsingBaseHTTPMiddleware] ________ [gw3] linux -- Python 3.12.3 /usr/bin/python3 + Exception Group Traceback (most recent call last): | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/_utils.py", line 87, in collapse_excgroups | yield | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/middleware/base.py", line 190, in __call__ | async with anyio.create_task_group() as task_group: | File "/usr/lib/python3.12/site-packages/anyio/_backends/_trio.py", line 169, in __aexit__ | return await self._nursery_manager.__aexit__(exc_type, exc_val, exc_tb) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/trio/_core/_run.py", line 954, in __aexit__ | raise combined_error_from_nursery | ExceptionGroup: Exceptions from Trio nursery (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "/usr/lib/python3.12/site-packages/_pytest/runner.py", line 340, in from_call | result: Optional[TResult] = func() | ^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/runner.py", line 240, in | lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_hooks.py", line 501, in __call__ | return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_manager.py", line 119, in _hookexec | return self._inner_hookexec(hook_name, methods, kwargs, firstresult) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 138, in _multicall | raise exception.with_traceback(exception.__traceback__) | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall | teardown.throw(exception) # type: ignore[union-attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/threadexception.py", line 87, in pytest_runtest_call | yield from thread_exception_runtest_hook() | File "/usr/lib/python3.12/site-packages/_pytest/threadexception.py", line 63, in thread_exception_runtest_hook | yield | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall | teardown.throw(exception) # type: ignore[union-attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/unraisableexception.py", line 90, in pytest_runtest_call | yield from unraisable_exception_runtest_hook() | File "/usr/lib/python3.12/site-packages/_pytest/unraisableexception.py", line 65, in unraisable_exception_runtest_hook | yield | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall | teardown.throw(exception) # type: ignore[union-attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/logging.py", line 849, in pytest_runtest_call | yield from self._runtest_for(item, "call") | File "/usr/lib/python3.12/site-packages/_pytest/logging.py", line 832, in _runtest_for | yield | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall | teardown.throw(exception) # type: ignore[union-attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/capture.py", line 883, in pytest_runtest_call | return (yield) | ^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall | teardown.throw(exception) # type: ignore[union-attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/skipping.py", line 256, in pytest_runtest_call | return (yield) | ^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 102, in _multicall | res = hook_impl.function(*args) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/runner.py", line 182, in pytest_runtest_call | raise e | File "/usr/lib/python3.12/site-packages/_pytest/runner.py", line 172, in pytest_runtest_call | item.runtest() | File "/usr/lib/python3.12/site-packages/_pytest/python.py", line 1772, in runtest | self.ihook.pytest_pyfunc_call(pyfuncitem=self) | File "/usr/lib/python3.12/site-packages/pluggy/_hooks.py", line 501, in __call__ | return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_manager.py", line 119, in _hookexec | return self._inner_hookexec(hook_name, methods, kwargs, firstresult) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 138, in _multicall | raise exception.with_traceback(exception.__traceback__) | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 102, in _multicall | res = hook_impl.function(*args) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/python.py", line 195, in pytest_pyfunc_call | result = testfunction(**testargs) | ^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/tests/middleware/test_base.py", line 258, in test_contextvars | response = client.get("/") | ^^^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/testclient.py", line 548, in get | return super().get( | ^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 1054, in get | return self.request( | ^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/testclient.py", line 516, in request | return super().request( | ^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 827, in request | return self.send(request, auth=auth, follow_redirects=follow_redirects) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 914, in send | response = self._send_handling_auth( | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 942, in _send_handling_auth | response = self._send_handling_redirects( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 979, in _send_handling_redirects | response = self._send_single_request(request) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 1015, in _send_single_request | response = transport.handle_request(request) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/testclient.py", line 398, in handle_request | raise exc | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/testclient.py", line 395, in handle_request | portal.call(self.app, scope, receive, send) | File "/usr/lib/python3.12/site-packages/anyio/from_thread.py", line 288, in call | return cast(T_Retval, self.start_task_soon(func, *args).result()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/concurrent/futures/_base.py", line 456, in result | return self.__get_result() | ^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result | raise self._exception | File "/usr/lib/python3.12/site-packages/anyio/from_thread.py", line 217, in _call_func | retval = await retval_or_awaitable | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/applications.py", line 123, in __call__ | await self.middleware_stack(scope, receive, send) | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/middleware/errors.py", line 186, in __call__ | raise exc | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/middleware/errors.py", line 164, in __call__ | await self.app(scope, receive, _send) | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/middleware/base.py", line 189, in __call__ | with collapse_excgroups(): | File "/usr/lib/python3.12/contextlib.py", line 158, in __exit__ | self.gen.throw(value) | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/_utils.py", line 93, in collapse_excgroups | raise exc | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/middleware/base.py", line 191, in __call__ | response = await self.dispatch_func(request, call_next) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/tests/middleware/test_base.py", line 221, in dispatch | assert ctxvar.get() == "set by endpoint" | AssertionError: assert 'set by middleware' == 'set by endpoint' | | - set by endpoint | + set by middleware +------------------------------------ During handling of the above exception, another exception occurred: test_client_factory = functools.partial(, backend='trio', backend_options={}) middleware_cls = @pytest.mark.parametrize( "middleware_cls", [ CustomMiddlewareWithoutBaseHTTPMiddleware, pytest.param( CustomMiddlewareUsingBaseHTTPMiddleware, marks=pytest.mark.xfail( reason=( "BaseHTTPMiddleware creates a TaskGroup which copies the context" "and erases any changes to it made within the TaskGroup" ), raises=AssertionError, ), ), ], ) def test_contextvars( test_client_factory: TestClientFactory, middleware_cls: type[_MiddlewareClass[Any]], ) -> None: # this has to be an async endpoint because Starlette calls run_in_threadpool # on sync endpoints which has it's own set of peculiarities w.r.t propagating # contextvars (it propagates them forwards but not backwards) async def homepage(request: Request) -> PlainTextResponse: assert ctxvar.get() == "set by middleware" ctxvar.set("set by endpoint") return PlainTextResponse("Homepage") app = Starlette( middleware=[Middleware(middleware_cls)], routes=[Route("/", homepage)] ) client = test_client_factory(app) > response = client.get("/") tests/middleware/test_base.py:258: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ starlette/testclient.py:548: in get return super().get( /usr/lib/python3.12/site-packages/httpx/_client.py:1054: in get return self.request( starlette/testclient.py:516: in request return super().request( /usr/lib/python3.12/site-packages/httpx/_client.py:827: in request return self.send(request, auth=auth, follow_redirects=follow_redirects) /usr/lib/python3.12/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.12/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.12/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) /usr/lib/python3.12/site-packages/httpx/_client.py:1015: in _send_single_request response = transport.handle_request(request) starlette/testclient.py:398: in handle_request raise exc starlette/testclient.py:395: in handle_request portal.call(self.app, scope, receive, send) /usr/lib/python3.12/site-packages/anyio/from_thread.py:288: in call return cast(T_Retval, self.start_task_soon(func, *args).result()) /usr/lib/python3.12/concurrent/futures/_base.py:456: in result return self.__get_result() /usr/lib/python3.12/concurrent/futures/_base.py:401: in __get_result raise self._exception /usr/lib/python3.12/site-packages/anyio/from_thread.py:217: in _call_func retval = await retval_or_awaitable starlette/applications.py:123: in __call__ await self.middleware_stack(scope, receive, send) starlette/middleware/errors.py:186: in __call__ raise exc starlette/middleware/errors.py:164: in __call__ await self.app(scope, receive, _send) starlette/middleware/base.py:189: in __call__ with collapse_excgroups(): /usr/lib/python3.12/contextlib.py:158: in __exit__ self.gen.throw(value) starlette/_utils.py:93: in collapse_excgroups raise exc starlette/middleware/base.py:191: in __call__ response = await self.dispatch_func(request, call_next) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = request = call_next = .call_next at 0xf5818a28> async def dispatch( self, request: Request, call_next: RequestResponseEndpoint, ) -> Response: ctxvar.set("set by middleware") resp = await call_next(request) > assert ctxvar.get() == "set by endpoint" E AssertionError: assert 'set by middleware' == 'set by endpoint' E E - set by endpoint E + set by middleware tests/middleware/test_base.py:221: AssertionError ______ test_contextvars[asyncio-CustomMiddlewareUsingBaseHTTPMiddleware] _______ [gw2] linux -- Python 3.12.3 /usr/bin/python3 + Exception Group Traceback (most recent call last): | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/_utils.py", line 87, in collapse_excgroups | yield | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/middleware/base.py", line 190, in __call__ | async with anyio.create_task_group() as task_group: | File "/usr/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 678, in __aexit__ | raise BaseExceptionGroup( | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "/usr/lib/python3.12/site-packages/_pytest/runner.py", line 340, in from_call | result: Optional[TResult] = func() | ^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/runner.py", line 240, in | lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_hooks.py", line 501, in __call__ | return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_manager.py", line 119, in _hookexec | return self._inner_hookexec(hook_name, methods, kwargs, firstresult) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 138, in _multicall | raise exception.with_traceback(exception.__traceback__) | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall | teardown.throw(exception) # type: ignore[union-attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/threadexception.py", line 87, in pytest_runtest_call | yield from thread_exception_runtest_hook() | File "/usr/lib/python3.12/site-packages/_pytest/threadexception.py", line 63, in thread_exception_runtest_hook | yield | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall | teardown.throw(exception) # type: ignore[union-attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/unraisableexception.py", line 90, in pytest_runtest_call | yield from unraisable_exception_runtest_hook() | File "/usr/lib/python3.12/site-packages/_pytest/unraisableexception.py", line 65, in unraisable_exception_runtest_hook | yield | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall | teardown.throw(exception) # type: ignore[union-attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/logging.py", line 849, in pytest_runtest_call | yield from self._runtest_for(item, "call") | File "/usr/lib/python3.12/site-packages/_pytest/logging.py", line 832, in _runtest_for | yield | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall | teardown.throw(exception) # type: ignore[union-attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/capture.py", line 883, in pytest_runtest_call | return (yield) | ^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall | teardown.throw(exception) # type: ignore[union-attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/skipping.py", line 256, in pytest_runtest_call | return (yield) | ^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 102, in _multicall | res = hook_impl.function(*args) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/runner.py", line 182, in pytest_runtest_call | raise e | File "/usr/lib/python3.12/site-packages/_pytest/runner.py", line 172, in pytest_runtest_call | item.runtest() | File "/usr/lib/python3.12/site-packages/_pytest/python.py", line 1772, in runtest | self.ihook.pytest_pyfunc_call(pyfuncitem=self) | File "/usr/lib/python3.12/site-packages/pluggy/_hooks.py", line 501, in __call__ | return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_manager.py", line 119, in _hookexec | return self._inner_hookexec(hook_name, methods, kwargs, firstresult) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 138, in _multicall | raise exception.with_traceback(exception.__traceback__) | File "/usr/lib/python3.12/site-packages/pluggy/_callers.py", line 102, in _multicall | res = hook_impl.function(*args) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/_pytest/python.py", line 195, in pytest_pyfunc_call | result = testfunction(**testargs) | ^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/tests/middleware/test_base.py", line 258, in test_contextvars | response = client.get("/") | ^^^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/testclient.py", line 548, in get | return super().get( | ^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 1054, in get | return self.request( | ^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/testclient.py", line 516, in request | return super().request( | ^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 827, in request | return self.send(request, auth=auth, follow_redirects=follow_redirects) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 914, in send | response = self._send_handling_auth( | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 942, in _send_handling_auth | response = self._send_handling_redirects( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 979, in _send_handling_redirects | response = self._send_single_request(request) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/site-packages/httpx/_client.py", line 1015, in _send_single_request | response = transport.handle_request(request) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/testclient.py", line 398, in handle_request | raise exc | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/testclient.py", line 395, in handle_request | portal.call(self.app, scope, receive, send) | File "/usr/lib/python3.12/site-packages/anyio/from_thread.py", line 288, in call | return cast(T_Retval, self.start_task_soon(func, *args).result()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/concurrent/futures/_base.py", line 456, in result | return self.__get_result() | ^^^^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result | raise self._exception | File "/usr/lib/python3.12/site-packages/anyio/from_thread.py", line 217, in _call_func | retval = await retval_or_awaitable | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/applications.py", line 123, in __call__ | await self.middleware_stack(scope, receive, send) | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/middleware/errors.py", line 186, in __call__ | raise exc | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/middleware/errors.py", line 164, in __call__ | await self.app(scope, receive, _send) | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/middleware/base.py", line 189, in __call__ | with collapse_excgroups(): | File "/usr/lib/python3.12/contextlib.py", line 158, in __exit__ | self.gen.throw(value) | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/_utils.py", line 93, in collapse_excgroups | raise exc | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/starlette/middleware/base.py", line 191, in __call__ | response = await self.dispatch_func(request, call_next) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/buildozer/aports/community/py3-starlette/src/starlette-0.37.2/tests/middleware/test_base.py", line 221, in dispatch | assert ctxvar.get() == "set by endpoint" | AssertionError: assert 'set by middleware' == 'set by endpoint' | | - set by endpoint | + set by middleware +------------------------------------ During handling of the above exception, another exception occurred: test_client_factory = functools.partial(, backend='asyncio', backend_options={}) middleware_cls = @pytest.mark.parametrize( "middleware_cls", [ CustomMiddlewareWithoutBaseHTTPMiddleware, pytest.param( CustomMiddlewareUsingBaseHTTPMiddleware, marks=pytest.mark.xfail( reason=( "BaseHTTPMiddleware creates a TaskGroup which copies the context" "and erases any changes to it made within the TaskGroup" ), raises=AssertionError, ), ), ], ) def test_contextvars( test_client_factory: TestClientFactory, middleware_cls: type[_MiddlewareClass[Any]], ) -> None: # this has to be an async endpoint because Starlette calls run_in_threadpool # on sync endpoints which has it's own set of peculiarities w.r.t propagating # contextvars (it propagates them forwards but not backwards) async def homepage(request: Request) -> PlainTextResponse: assert ctxvar.get() == "set by middleware" ctxvar.set("set by endpoint") return PlainTextResponse("Homepage") app = Starlette( middleware=[Middleware(middleware_cls)], routes=[Route("/", homepage)] ) client = test_client_factory(app) > response = client.get("/") tests/middleware/test_base.py:258: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ starlette/testclient.py:548: in get return super().get( /usr/lib/python3.12/site-packages/httpx/_client.py:1054: in get return self.request( starlette/testclient.py:516: in request return super().request( /usr/lib/python3.12/site-packages/httpx/_client.py:827: in request return self.send(request, auth=auth, follow_redirects=follow_redirects) /usr/lib/python3.12/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.12/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.12/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) /usr/lib/python3.12/site-packages/httpx/_client.py:1015: in _send_single_request response = transport.handle_request(request) starlette/testclient.py:398: in handle_request raise exc starlette/testclient.py:395: in handle_request portal.call(self.app, scope, receive, send) /usr/lib/python3.12/site-packages/anyio/from_thread.py:288: in call return cast(T_Retval, self.start_task_soon(func, *args).result()) /usr/lib/python3.12/concurrent/futures/_base.py:456: in result return self.__get_result() /usr/lib/python3.12/concurrent/futures/_base.py:401: in __get_result raise self._exception /usr/lib/python3.12/site-packages/anyio/from_thread.py:217: in _call_func retval = await retval_or_awaitable starlette/applications.py:123: in __call__ await self.middleware_stack(scope, receive, send) starlette/middleware/errors.py:186: in __call__ raise exc starlette/middleware/errors.py:164: in __call__ await self.app(scope, receive, _send) starlette/middleware/base.py:189: in __call__ with collapse_excgroups(): /usr/lib/python3.12/contextlib.py:158: in __exit__ self.gen.throw(value) starlette/_utils.py:93: in collapse_excgroups raise exc starlette/middleware/base.py:191: in __call__ response = await self.dispatch_func(request, call_next) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = request = call_next = .call_next at 0xf59c6348> async def dispatch( self, request: Request, call_next: RequestResponseEndpoint, ) -> Response: ctxvar.set("set by middleware") resp = await call_next(request) > assert ctxvar.get() == "set by endpoint" E AssertionError: assert 'set by middleware' == 'set by endpoint' E E - set by endpoint E + set by middleware tests/middleware/test_base.py:221: AssertionError =========================== short test summary info ============================ XFAIL tests/middleware/test_base.py::test_contextvars[trio-CustomMiddlewareUsingBaseHTTPMiddleware] - BaseHTTPMiddleware creates a TaskGroup which copies the contextand erases any changes to it made within the TaskGroup XFAIL tests/middleware/test_base.py::test_contextvars[asyncio-CustomMiddlewareUsingBaseHTTPMiddleware] - BaseHTTPMiddleware creates a TaskGroup which copies the contextand erases any changes to it made within the TaskGroup ======================== 793 passed, 2 xfailed in 9.13s ======================== >>> py3-starlette: Entering fakeroot... >>> py3-starlette-pyc*: Running split function pyc... '/home/buildozer/aports/community/py3-starlette/pkg/py3-starlette/usr/lib/python3.12/site-packages/starlette/__pycache__' -> '/home/buildozer/aports/community/py3-starlette/pkg/py3-starlette-pyc/usr/lib/python3.12/site-packages/starlette/__pycache__' '/home/buildozer/aports/community/py3-starlette/pkg/py3-starlette/usr/lib/python3.12/site-packages/starlette/middleware/__pycache__' -> '/home/buildozer/aports/community/py3-starlette/pkg/py3-starlette-pyc/usr/lib/python3.12/site-packages/starlette/middleware/__pycache__' >>> py3-starlette-pyc*: Preparing subpackage py3-starlette-pyc... >>> py3-starlette-pyc*: Running postcheck for py3-starlette-pyc >>> py3-starlette*: Running postcheck for py3-starlette >>> py3-starlette*: Preparing package py3-starlette... >>> py3-starlette-pyc*: Tracing dependencies... py3-anyio python3~3.12 >>> py3-starlette-pyc*: Package size: 424.0 KB >>> py3-starlette-pyc*: Compressing data... >>> py3-starlette-pyc*: Create checksum... >>> py3-starlette-pyc*: Create py3-starlette-pyc-0.37.2-r1.apk >>> py3-starlette*: Tracing dependencies... py3-anyio python3~3.12 >>> py3-starlette*: Package size: 380.0 KB >>> py3-starlette*: Compressing data... >>> py3-starlette*: Create checksum... >>> py3-starlette*: Create py3-starlette-0.37.2-r1.apk >>> py3-starlette: Build complete at Sat, 27 Apr 2024 03:17:20 +0000 elapsed time 0h 0m 16s >>> py3-starlette: Cleaning up srcdir >>> py3-starlette: Cleaning up pkgdir >>> py3-starlette: Uninstalling dependencies... (1/92) Purging .makedepends-py3-starlette (20240427.031707) (2/92) Purging py3-gpep517-pyc (15-r2) (3/92) Purging py3-gpep517 (15-r2) (4/92) Purging py3-hatchling-pyc (1.24.1-r0) (5/92) Purging py3-hatchling (1.24.1-r0) (6/92) Purging py3-editables-pyc (0.5-r2) (7/92) Purging py3-editables (0.5-r2) (8/92) Purging py3-pathspec-pyc (0.12.1-r2) (9/92) Purging py3-pathspec (0.12.1-r2) (10/92) Purging py3-trove-classifiers-pyc (2024.3.3-r2) (11/92) Purging py3-trove-classifiers (2024.3.3-r2) (12/92) Purging py3-installer-pyc (0.7.0-r2) (13/92) Purging py3-installer (0.7.0-r2) (14/92) Purging py3-httpx-pyc (0.27.0-r1) (15/92) Purging py3-httpx (0.27.0-r1) (16/92) Purging py3-httpcore-pyc (1.0.4-r1) (17/92) Purging py3-httpcore (1.0.4-r1) (18/92) Purging py3-anyio-pyc (4.3.0-r2) (19/92) Purging py3-anyio (4.3.0-r2) (20/92) Purging py3-certifi-pyc (2024.2.2-r1) (21/92) Purging py3-certifi (2024.2.2-r1) (22/92) Purging py3-h11-pyc (0.14.0-r4) (23/92) Purging py3-h11 (0.14.0-r4) (24/92) Purging py3-itsdangerous-pyc (2.1.2-r4) (25/92) Purging py3-itsdangerous (2.1.2-r4) (26/92) Purging py3-jinja2-pyc (3.1.3-r1) (27/92) Purging py3-jinja2 (3.1.3-r1) (28/92) Purging py3-markupsafe-pyc (2.1.5-r1) (29/92) Purging py3-markupsafe (2.1.5-r1) (30/92) Purging py3-pytest-forked-pyc (1.6.0-r2) (31/92) Purging py3-pytest-forked (1.6.0-r2) (32/92) Purging py3-pytest-xdist-pyc (3.5.0-r1) (33/92) Purging py3-pytest-xdist (3.5.0-r1) (34/92) Purging py3-execnet-pyc (1.9.0-r3) (35/92) Purging py3-execnet (1.9.0-r3) (36/92) Purging py3-apipkg-pyc (2.1.0-r3) (37/92) Purging py3-apipkg (2.1.0-r3) (38/92) Purging py3-pytest-pyc (8.1.1-r1) (39/92) Purging py3-pytest (8.1.1-r1) (40/92) Purging py3-iniconfig-pyc (2.0.0-r1) (41/92) Purging py3-iniconfig (2.0.0-r1) (42/92) Purging py3-packaging-pyc (24.0-r1) (43/92) Purging py3-packaging (24.0-r1) (44/92) Purging py3-parsing-pyc (3.1.2-r1) (45/92) Purging py3-parsing (3.1.2-r1) (46/92) Purging py3-pluggy-pyc (1.4.0-r1) (47/92) Purging py3-pluggy (1.4.0-r1) (48/92) Purging py3-py-pyc (1.11.0-r3) (49/92) Purging py3-py (1.11.0-r3) (50/92) Purging py3-python-multipart-pyc (0.0.9-r1) (51/92) Purging py3-python-multipart (0.0.9-r1) (52/92) Purging py3-trio-pyc (0.25.0-r1) (53/92) Purging py3-trio (0.25.0-r1) (54/92) Purging py3-idna-pyc (3.7-r0) (55/92) Purging py3-idna (3.7-r0) (56/92) Purging py3-openssl-pyc (24.1.0-r1) (57/92) Purging py3-openssl (24.1.0-r1) (58/92) Purging py3-cryptography-pyc (42.0.5-r1) (59/92) Purging py3-cryptography (42.0.5-r1) (60/92) Purging py3-cffi-pyc (1.16.0-r1) (61/92) Purging py3-cffi (1.16.0-r1) (62/92) Purging py3-cparser-pyc (2.22-r1) (63/92) Purging py3-cparser (2.22-r1) (64/92) Purging py3-outcome-pyc (1.3.0-r1) (65/92) Purging py3-outcome (1.3.0-r1) (66/92) Purging py3-async_generator-pyc (1.10-r6) (67/92) Purging py3-async_generator (1.10-r6) (68/92) Purging py3-attrs-pyc (23.2.0-r1) (69/92) Purging py3-attrs (23.2.0-r1) (70/92) Purging py3-sniffio-pyc (1.3.1-r1) (71/92) Purging py3-sniffio (1.3.1-r1) (72/92) Purging py3-curio-pyc (1.6-r2) (73/92) Purging py3-curio (1.6-r2) (74/92) Purging py3-sortedcontainers-pyc (2.4.0-r5) (75/92) Purging py3-sortedcontainers (2.4.0-r5) (76/92) Purging py3-typing-extensions-pyc (4.11.0-r1) (77/92) Purging py3-typing-extensions (4.11.0-r1) (78/92) Purging py3-yaml-pyc (6.0.1-r3) (79/92) Purging py3-yaml (6.0.1-r3) (80/92) Purging python3-pyc (3.12.3-r1) (81/92) Purging python3-pycache-pyc0 (3.12.3-r1) (82/92) Purging pyc (3.12.3-r1) (83/92) Purging python3 (3.12.3-r1) (84/92) Purging gdbm (1.23-r1) (85/92) Purging libbz2 (1.0.8-r6) (86/92) Purging libffi (3.4.6-r0) (87/92) Purging libpanelw (6.4_p20240330-r0) (88/92) Purging mpdecimal (4.0.0-r0) (89/92) Purging readline (8.2.10-r0) (90/92) Purging sqlite-libs (3.45.3-r0) (91/92) Purging xz-libs (5.6.1-r3) (92/92) Purging yaml (0.2.5-r2) Executing busybox-1.36.1-r26.trigger OK: 376 MiB in 102 packages >>> py3-starlette: Updating the community/x86 repository index... >>> py3-starlette: Signing the index...