python-trio/pytest-trio

TrioDeprecationWarning: trio.MultiError is deprecated since Trio 0.22.0

richardsheridan opened this issue · 2 comments

For a trivial environment and failing test, warnings are generated due to the direct usage of multierror:
pip install pytest-trio
echo "from pytest_trio.enable_trio_mode import *" > conftest.py
echo "async def test_warning(): assert False" > test_warning.py

Output

(tmp) C:\Users\richa\Documents\GitHub\tmp>pytest test_warning.py
============================= test session starts =============================
platform win32 -- Python 3.10.6, pytest-7.1.3, pluggy-1.0.0
rootdir: C:\Users\richa\Documents\GitHub\tmp
plugins: trio-0.7.0
collected 1 item

test_warning.py F                                                        [100%]

================================== FAILURES =================================== 
________________________________ test_warning _________________________________ 

value = <trio.Nursery object at 0x000001A125D6B550>

    async def yield_(value=None):
>       return await _yield_(value)

..\..\..\miniconda3\envs\tmp\lib\site-packages\async_generator\_impl.py:106:    
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
..\..\..\miniconda3\envs\tmp\lib\site-packages\async_generator\_impl.py:99: in _yield_
    return (yield _wrap(value))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    async def test_warning():
>       assert False
E       assert False

test_warning.py:3: AssertionError
============================== warnings summary =============================== 
test_warning.py::test_warning
  C:\Users\richa\miniconda3\envs\tmp\lib\site-packages\pytest_trio\plugin.py:409
: TrioDeprecationWarning: trio.MultiError is deprecated since Trio 0.22.0; use B
aseExceptionGroup (on Python 3.11 and later) or exceptiongroup.BaseExceptionGroup 
(earlier versions) instead (https://github.com/python-trio/trio/issues/2211)  
    raise trio.MultiError(test_ctx.error_list)

test_warning.py::test_warning
  C:\Users\richa\miniconda3\envs\tmp\lib\site-packages\pytest_trio\plugin.py:62:
 TrioDeprecationWarning: trio.MultiError is deprecated since Trio 0.22.0; use Ba
seExceptionGroup (on Python 3.11 and later) or exceptiongroup.BaseExceptionGroup 
(earlier versions) instead (https://github.com/python-trio/trio/issues/2211)   
    if issubclass(call.excinfo.type, trio.MultiError):

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info =========================== 
FAILED test_warning.py::test_warning - assert False
======================== 1 failed, 2 warnings in 0.13s ======================== 

Probably easier said than done, but I think pytest-trio should migrate to ExceptionGroup and release a new version that requires Trio 0.22.

I released pytest-trio 0.8.0 with ExceptionGroup support. Thank you @Zac-HD!