Closed
Description
Describe the bug
Starting with syrupy 4.6.3, tests that are marked with @pytest.mark.flaky
for pytest-rerunfailures cause internal error ValueError: 'rerun' is not a valid ItemStatus
. The error happens on this line, which was introduced in 3f6e301.
This happens because pytest-rerunfailures sets the outcome to the value "rerun"
on this line.
To reproduce
pip install pytest pytest-rerunfailures syrupy
test_example.py:
import pytest
@pytest.mark.flaky(reruns=1, delay=0)
def test_failing():
assert False
The outcome you get with 4.6.3 is:
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/_pytest/main.py", line 283, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/_pytest/main.py", line 337, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> raise exception.with_traceback(exception.__traceback__)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR> teardown.throw(exception) # type: ignore[union-attr]
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/_pytest/logging.py", line 805, in pytest_runtestloop
INTERNALERROR> return (yield) # Run all the tests.
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR> teardown.throw(exception) # type: ignore[union-attr]
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/_pytest/terminal.py", line 673, in pytest_runtestloop
INTERNALERROR> result = yield
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/_pytest/main.py", line 362, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> raise exception.with_traceback(exception.__traceback__)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR> teardown.throw(exception) # type: ignore[union-attr]
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/_pytest/warnings.py", line 112, in pytest_runtest_protocol
INTERNALERROR> return (yield)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR> teardown.throw(exception) # type: ignore[union-attr]
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/_pytest/assertion/__init__.py", line 176, in pytest_runtest_protocol
INTERNALERROR> return (yield)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR> teardown.throw(exception) # type: ignore[union-attr]
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/_pytest/unittest.py", line 429, in pytest_runtest_protocol
INTERNALERROR> res = yield
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR> teardown.throw(exception) # type: ignore[union-attr]
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/_pytest/faulthandler.py", line 87, in pytest_runtest_protocol
INTERNALERROR> return (yield)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pytest_rerunfailures.py", line 563, in pytest_runtest_protocol
INTERNALERROR> item.ihook.pytest_runtest_logreport(report=report)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> raise exception.with_traceback(exception.__traceback__)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/syrupy/__init__.py", line 157, in pytest_runtest_logreport
INTERNALERROR> _syrupy.ran_item(report.nodeid, report.outcome)
INTERNALERROR> File "/Users/jcheng/Development/scratchpad/syrupy-reprex/.venv/lib/python3.10/site-packages/syrupy/session.py", line 125, in ran_item
INTERNALERROR> self._selected_items[nodeid] = ItemStatus(outcome)
INTERNALERROR> File "/Users/jcheng/.pyenv/versions/3.10.6/lib/python3.10/enum.py", line 385, in __call__
INTERNALERROR> return cls.__new__(cls, value)
INTERNALERROR> File "/Users/jcheng/.pyenv/versions/3.10.6/lib/python3.10/enum.py", line 710, in __new__
INTERNALERROR> raise ve_exc
INTERNALERROR> ValueError: 'rerun' is not a valid ItemStatus
====================================================================================== 1 rerun in 0.02s ======================================================================================
Expected behavior
The desired output looks like this (using syrupy 4.6.2):
========================================================================================== FAILURES ==========================================================================================
________________________________________________________________________________________ test_failing ________________________________________________________________________________________
@pytest.mark.flaky(reruns=1, delay=0)
def test_failing():
> assert False
E assert False
test_example.py:5: AssertionError
================================================================================== short test summary info ===================================================================================
FAILED test_example.py::test_failing - assert False
================================================================================= 1 failed, 1 rerun in 0.02s =================================================================================
Environment (please complete the following information):
- OS: macOS 14.5
- Syrupy Version: 4.6.3
- Python Version: 3.10