Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing tests: 'lifespan.startup' != 'http.request' #63

Open
EdwardBetts opened this issue Jul 17, 2024 · 0 comments
Open

Failing tests: 'lifespan.startup' != 'http.request' #63

EdwardBetts opened this issue Jul 17, 2024 · 0 comments

Comments

@EdwardBetts
Copy link
Contributor

$ python3 -mpytest --no-cov -c /dev/null --asyncio-mode=strict -p no:cacheprovider --tb=no ../tests 
====================================================================================== test session starts ======================================================================================
platform linux -- Python 3.12.4, pytest-8.2.2, pluggy-1.5.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /dev
configfile: null
plugins: timeout-2.3.1, tornasync-0.6.0.post2, pytest_httpserver-1.0.10, benchmark-4.0.0, trio-0.8.0, respx-0.21.1, anyio-4.4.0, cov-5.0.0, twisted-1.14.1, asyncio-0.20.3, lazy-fixtures-1.0.7, kgb-7.1.1, httpx-0.30.0, mock-3.14.0, requests-mock-1.12.1, hypothesis-6.105.1
asyncio: mode=Mode.STRICT
collected 32 items                                                                                                                                                                              

../../../../../../dev/test_manager.py .........FFFFF.F...F......xFFF..                                                                                                                    [100%]

======================================================================================= warnings summary ========================================================================================
test_manager.py: 12 warnings
  /usr/lib/python3/dist-packages/starlette/routing.py:638: DeprecationWarning: The on_startup and on_shutdown parameters are deprecated, and they will be removed on version 1.0. Use the lifespan parameter instead. See more about it on https://www.starlette.io/lifespan/.
    warnings.warn(

test_manager.py::test_lifespan_state_async_cm[asyncio]
test_manager.py::test_lifespan_state_async_cm[trio]
  /usr/lib/python3/dist-packages/httpx/_client.py:1426: DeprecationWarning: The 'app' shortcut is now deprecated. Use the explicit style 'transport=ASGITransport(app=...)' instead.
    warnings.warn(message, DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================================================================== short test summary info ====================================================================================
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-None-None-StartupFailed] - ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-None-BodyFailed-None] - ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-None-BodyFailed-StartupFailed] - ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-ShutdownFailed-None-None] - ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-ShutdownFailed-None-StartupFailed] - ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-ShutdownFailed-BodyFailed-StartupFailed] - ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
FAILED ../../../../../../dev/test_manager.py::test_lifespan_timeout[trio-slow_shutdown] - ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
FAILED ../../../../../../dev/test_manager.py::test_lifespan_not_supported[trio-http_only] - ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
FAILED ../../../../../../dev/test_manager.py::test_lifespan_not_supported[trio-http_no_assert] - ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
FAILED ../../../../../../dev/test_manager.py::test_lifespan_not_supported[trio-http_no_assert_before_receive_request] - ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
===================================================================== 10 failed, 21 passed, 1 xfailed, 14 warnings in 0.53s =====================================================================
$ 

When I run the tests so it shows tracebacks there is a lot of output that ends like this:

  +-+---------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    |   File "/usr/lib/python3/dist-packages/pytest_trio/plugin.py", line 195, in _fixture_manager
    |     yield nursery_fixture
    |   File "/usr/lib/python3/dist-packages/pytest_trio/plugin.py", line 250, in run
    |     await self._func(**resolved_kwargs)
    |   File "/home/edward/scratch/asgi-lifespan/asgi-lifespan-2.1.0/tests/test_manager.py", line 225, in test_lifespan_not_supported
    |     async with LifespanManager(app):
    |   File "/home/edward/scratch/asgi-lifespan/asgi-lifespan-2.1.0/src/asgi_lifespan/_manager.py", line 102, in __aenter__
    |     await self._exit_stack.aclose()
    |   File "/usr/lib/python3.12/contextlib.py", line 696, in aclose
    |     await self.__aexit__(None, None, None)
    |   File "/usr/lib/python3.12/contextlib.py", line 754, in __aexit__
    |     raise exc_details[1]
    |   File "/usr/lib/python3.12/contextlib.py", line 737, in __aexit__
    |     cb_suppress = await cb(*exc_details)
    |                   ^^^^^^^^^^^^^^^^^^^^^^
    |   File "/home/edward/scratch/asgi-lifespan/asgi-lifespan-2.1.0/src/asgi_lifespan/_concurrency/trio.py", line 72, in __aexit__
    |     await self._exit_stack.__aexit__(exc_type, exc_value, traceback)
    |   File "/usr/lib/python3.12/contextlib.py", line 754, in __aexit__
    |     raise exc_details[1]
    |   File "/usr/lib/python3.12/contextlib.py", line 737, in __aexit__
    |     cb_suppress = await cb(*exc_details)
    |                   ^^^^^^^^^^^^^^^^^^^^^^
    |   File "/usr/lib/python3/dist-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 "/home/edward/scratch/asgi-lifespan/asgi-lifespan-2.1.0/src/asgi_lifespan/_manager.py", line 99, in __aenter__
      |     await self.startup()
      |   File "/home/edward/scratch/asgi-lifespan/asgi-lifespan-2.1.0/src/asgi_lifespan/_manager.py", line 45, in startup
      |     raise self._app_exception
      |   File "/home/edward/scratch/asgi-lifespan/asgi-lifespan-2.1.0/src/asgi_lifespan/_manager.py", line 73, in run_app
      |     await self.app(scope, self.receive, self.send)
      |   File "/home/edward/scratch/asgi-lifespan/asgi-lifespan-2.1.0/src/asgi_lifespan/_manager.py", line 13, in app_with_state
      |     await app(scope, receive, send)
      |   File "/home/edward/scratch/asgi-lifespan/asgi-lifespan-2.1.0/tests/test_manager.py", line 204, in http_no_assert_before_receive_request
      |     assert message["type"] == "http.request"
      | AssertionError: assert 'lifespan.startup' == 'http.request'
      |   
      |   - http.request
      |   + lifespan.startup
      +------------------------------------
=============================== warnings summary ===============================
test_manager.py: 12 warnings
  /usr/lib/python3/dist-packages/starlette/routing.py:638: DeprecationWarning: The on_startup and on_shutdown parameters are deprecated, and they will be removed on version 1.0. Use the lifespan parameter instead. See more about it on https://www.starlette.io/lifespan/.
    warnings.warn(

test_manager.py::test_lifespan_state_async_cm[asyncio]
test_manager.py::test_lifespan_state_async_cm[trio]
  /usr/lib/python3/dist-packages/httpx/_client.py:1426: DeprecationWarning: The 'app' shortcut is now deprecated. Use the explicit style 'transport=ASGITransport(app=...)' instead.
    warnings.warn(message, DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-None-None-StartupFailed]
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-None-BodyFailed-None]
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-None-BodyFailed-StartupFailed]
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-ShutdownFailed-None-None]
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-ShutdownFailed-None-StartupFailed]
FAILED ../../../../../../dev/test_manager.py::test_lifespan_manager[trio-ShutdownFailed-BodyFailed-StartupFailed]
FAILED ../../../../../../dev/test_manager.py::test_lifespan_timeout[trio-slow_shutdown]
FAILED ../../../../../../dev/test_manager.py::test_lifespan_not_supported[trio-http_only]
FAILED ../../../../../../dev/test_manager.py::test_lifespan_not_supported[trio-http_no_assert]
FAILED ../../../../../../dev/test_manager.py::test_lifespan_not_supported[trio-http_no_assert_before_receive_request]
============ 10 failed, 21 passed, 1 xfailed, 14 warnings in 0.64s =============
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant