Closed tking16 closed 10 months ago
I do not know about a the possibility to identify that a re-run is currently in progress.
There is item.execution_count
, see https://github.com/pytest-dev/pytest-rerunfailures/blob/c6ff082a36e927b27fd8418737f49e116d03a22a/pytest_rerunfailures.py#L606C1-L607C1 But you are probably not able to access item
during a test run.
But you are probably not able to access
item
during a test run.
You can, via the request
fixture and request.node
- e.g.:
def test_rerun(request):
if request.node.execution_count == 1:
1/0
results in:
test_x.py::test_rerun RERUN
test_x.py::test_rerun PASSED
Thank you @The-Compiler for sharing your knowledge. I assume the question as answered and will set the issue to resolved.
Hi, I have a quick general question. I'd like to start a screen recording only when a test has failed and has is on a rerun. Is there some way to identify that a test is being reran? I tried
request.config.option.lf
but it just returnsfalse
whether a test is being run for the first time or not!