agronholm / exceptiongroup

Backport of PEP 654 (exception groups)
Other
42 stars 20 forks source link

Multiple formatting tests fail with Python 3.13.0b1 #122

Closed mgorny closed 3 months ago

mgorny commented 5 months ago

Things to check first

Exceptiongroup version

54d8b8d9208bfc8f1e89c052e45e89328491ca06

Python version

3.13.0b1

What happened?

Running the test suite against Python 3.13, I'm getting a bunch of test failures:

========================================================= test session starts =========================================================
platform linux -- Python 3.13.0b1, pytest-8.2.0, pluggy-1.5.0
rootdir: /tmp/exceptiongroup
configfile: pyproject.toml
testpaths: tests
collected 100 items                                                                                                                   

tests/test_apport_monkeypatching.py s                                                                                           [  1%]
tests/test_catch.py .................                                                                                           [ 18%]
tests/test_catch_py311.py ..........                                                                                            [ 28%]
tests/test_exceptions.py ............................................                                                           [ 72%]
tests/test_formatting.py F..FFFFssF..ssFFssFs.s.s.s.                                                                            [ 99%]
tests/test_suppress.py .                                                                                                        [100%]

============================================================== FAILURES ===============================================================
_________________________________________________________ test_exceptionhook __________________________________________________________
tests/test_formatting.py:68: in test_exceptionhook
    assert output == (
E   assert '  + Exceptio...-----------\n' == '  + Exceptio...-----------\n'
E     
E     Skipping 166 identical leading characters in diff, use -v to show
E       p()
E     +   |     ~~~~~~~~~~~~~~^^
E         |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
E         |     raise exc
E         | ExceptionGroup: test message (2 sub-exceptions)...
E     
E     ...Full output truncated (13 lines hidden), use '-vv' to show
______________________________________________ test_exceptionhook_format_exception_only _______________________________________________
tests/test_formatting.py:167: in test_exceptionhook_format_exception_only
    assert output == (
E   assert '  + Exceptio...-----------\n' == '  + Exceptio...-----------\n'
E     
E     Skipping 189 identical leading characters in diff, use -v to show
E       p()
E     +   |     ~~~~~~~~~~~~~~^^
E         |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
E         |     raise exc
E         | ExceptionGroup: test message (2 sub-exceptions)...
E     
E     ...Full output truncated (13 lines hidden), use '-vv' to show
____________________________________________________ test_formatting_syntax_error _____________________________________________________
tests/test_formatting.py:208: in test_formatting_syntax_error
    assert output == (
E   assert 'Traceback (m...alid syntax\n' == 'Traceback (m...alid syntax\n'
E     
E     Skipping 145 identical leading characters in diff, use -v to show
E       erser")
E     +     ~~~~^^^^^^^^^^^^
E         File "<string>", line 1
E           //serser
E           ^^
E       SyntaxError: invalid syntax
_______________________________________________ test_format_exception[patched-newstyle] _______________________________________________
  + Exception Group Traceback (most recent call last):
  |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 246, in test_format_exception
  |     raise_excgroup()
  |     ~~~~~~~~~~~~~~^^
  |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
  |     raise exc
  | ExceptionGroup: test message (2 sub-exceptions)
  | Displays notes attached to the group too
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 17, in raise_excgroup
    |     raise ValueError("foo")
    | ValueError: foo
    +---------------- 2 ----------------
    | Traceback (most recent call last):
    |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 22, in raise_excgroup
    |     raise RuntimeError("bar")
    | RuntimeError: bar
    | Note from bar handler
    +------------------------------------

During handling of the above exception, another exception occurred:
tests/test_formatting.py:257: in test_format_exception
    assert "".join(lines) == (
E   assert '  + Exceptio...-----------\n' == '  + Exceptio...-----------\n'
E     
E     Skipping 170 identical leading characters in diff, use -v to show
E       p()
E     +   |     ~~~~~~~~~~~~~~^^
E         |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
E         |     raise exc
E         | ExceptionGroup: test message (2 sub-exceptions)...
E     
E     ...Full output truncated (13 lines hidden), use '-vv' to show
_______________________________________________ test_format_exception[patched-oldstyle] _______________________________________________
  + Exception Group Traceback (most recent call last):
  |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 246, in test_format_exception
  |     raise_excgroup()
  |     ~~~~~~~~~~~~~~^^
  |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
  |     raise exc
  | ExceptionGroup: test message (2 sub-exceptions)
  | Displays notes attached to the group too
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 17, in raise_excgroup
    |     raise ValueError("foo")
    | ValueError: foo
    +---------------- 2 ----------------
    | Traceback (most recent call last):
    |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 22, in raise_excgroup
    |     raise RuntimeError("bar")
    | RuntimeError: bar
    | Note from bar handler
    +------------------------------------

During handling of the above exception, another exception occurred:
tests/test_formatting.py:257: in test_format_exception
    assert "".join(lines) == (
E   assert '  + Exceptio...-----------\n' == '  + Exceptio...-----------\n'
E     
E     Skipping 170 identical leading characters in diff, use -v to show
E       p()
E     +   |     ~~~~~~~~~~~~~~^^
E         |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
E         |     raise exc
E         | ExceptionGroup: test message (2 sub-exceptions)...
E     
E     ...Full output truncated (13 lines hidden), use '-vv' to show
_________________________________________________________ test_format_nested __________________________________________________________
tests/test_formatting.py:311: in test_format_nested
    assert "".join(lines) == (
E   assert 'Traceback (m...on: LEVEL_1\n' == 'Traceback (m...on: LEVEL_1\n'
E     
E     Skipping 141 identical leading characters in diff, use -v to show
E       el + 1)
E     +     ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
E         File "/tmp/exceptiongroup/tests/test_formatting.py", line 294, in raise_exc
E           raise Exception(f"LEVEL_{level}")
E       Exception: LEVEL_3...
E     
E     ...Full output truncated (20 lines hidden), use '-vv' to show
_______________________________________________ test_print_exception[patched-newstyle] ________________________________________________
  + Exception Group Traceback (most recent call last):
  |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 381, in test_print_exception
  |     raise_excgroup()
  |     ~~~~~~~~~~~~~~^^
  |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
  |     raise exc
  | ExceptionGroup: test message (2 sub-exceptions)
  | Displays notes attached to the group too
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 17, in raise_excgroup
    |     raise ValueError("foo")
    | ValueError: foo
    +---------------- 2 ----------------
    | Traceback (most recent call last):
    |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 22, in raise_excgroup
    |     raise RuntimeError("bar")
    | RuntimeError: bar
    | Note from bar handler
    +------------------------------------

During handling of the above exception, another exception occurred:
tests/test_formatting.py:392: in test_print_exception
    assert output == (
E   assert '  + Exceptio...-----------\n' == '  + Exceptio...-----------\n'
E     
E     Skipping 169 identical leading characters in diff, use -v to show
E       p()
E     +   |     ~~~~~~~~~~~~~~^^
E         |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
E         |     raise exc
E         | ExceptionGroup: test message (2 sub-exceptions)...
E     
E     ...Full output truncated (13 lines hidden), use '-vv' to show
_______________________________________________ test_print_exception[patched-oldstyle] ________________________________________________
  + Exception Group Traceback (most recent call last):
  |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 381, in test_print_exception
  |     raise_excgroup()
  |     ~~~~~~~~~~~~~~^^
  |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
  |     raise exc
  | ExceptionGroup: test message (2 sub-exceptions)
  | Displays notes attached to the group too
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 17, in raise_excgroup
    |     raise ValueError("foo")
    | ValueError: foo
    +---------------- 2 ----------------
    | Traceback (most recent call last):
    |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 22, in raise_excgroup
    |     raise RuntimeError("bar")
    | RuntimeError: bar
    | Note from bar handler
    +------------------------------------

During handling of the above exception, another exception occurred:
tests/test_formatting.py:392: in test_print_exception
    assert output == (
E   assert '  + Exceptio...-----------\n' == '  + Exceptio...-----------\n'
E     
E     Skipping 169 identical leading characters in diff, use -v to show
E       p()
E     +   |     ~~~~~~~~~~~~~~^^
E         |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
E         |     raise exc
E         | ExceptionGroup: test message (2 sub-exceptions)...
E     
E     ...Full output truncated (13 lines hidden), use '-vv' to show
_______________________________________________________ test_print_exc[patched] _______________________________________________________
  + Exception Group Traceback (most recent call last):
  |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 430, in test_print_exc
  |     raise_excgroup()
  |     ~~~~~~~~~~~~~~^^
  |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
  |     raise exc
  | ExceptionGroup: test message (2 sub-exceptions)
  | Displays notes attached to the group too
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 17, in raise_excgroup
    |     raise ValueError("foo")
    | ValueError: foo
    +---------------- 2 ----------------
    | Traceback (most recent call last):
    |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 22, in raise_excgroup
    |     raise RuntimeError("bar")
    | RuntimeError: bar
    | Note from bar handler
    +------------------------------------

During handling of the above exception, another exception occurred:
tests/test_formatting.py:437: in test_print_exc
    assert output == (
E   assert '  + Exceptio...-----------\n' == '  + Exceptio...-----------\n'
E     
E     Skipping 163 identical leading characters in diff, use -v to show
E       p()
E     +   |     ~~~~~~~~~~~~~~^^
E         |   File "/tmp/exceptiongroup/tests/test_formatting.py", line 29, in raise_excgroup
E         |     raise exc
E         | ExceptionGroup: test message (2 sub-exceptions)...
E     
E     ...Full output truncated (13 lines hidden), use '-vv' to show
======================================================= short test summary info =======================================================
SKIPPED [1] tests/test_apport_monkeypatching.py:39: need Ubuntu with python3-apport installed
SKIPPED [2] tests/test_formatting.py:221: No patching is done on Python >= 3.11
SKIPPED [2] tests/test_formatting.py:341: No patching is done on Python >= 3.11
SKIPPED [2] tests/test_formatting.py:368: No patching is done on Python >= 3.11
SKIPPED [1] tests/test_formatting.py:417: No patching is done on Python >= 3.11
SKIPPED [1] tests/test_formatting.py:462: No patching is done on Python >= 3.11
SKIPPED [1] tests/test_formatting.py:486: No patching is done on Python >= 3.11
SKIPPED [1] tests/test_formatting.py:511: No patching is done on Python >= 3.11
============================================== 9 failed, 80 passed, 11 skipped in 0.19s ===============================================

How can we reproduce the bug?

pip install . pytest
python3.13 -m pytest
mgorny commented 3 months ago

Thanks!