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

Logs before rerun appear in html report #787

Open
orgads opened this issue Dec 22, 2023 · 8 comments
Open

Logs before rerun appear in html report #787

orgads opened this issue Dec 22, 2023 · 8 comments

Comments

@orgads
Copy link

orgads commented Dec 22, 2023

import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
seq_num = 0

def seq():
  global seq_num
  seq_num += 1
  return seq_num

def test_fail():
  logger.info(f'Test log {seq()}')
  assert False

pytest --reruns 1 --html=report.html

The report has logs of both runs:

def test_fail():
      logger.info(f'Test log {seq()}')
>     assert False
E     assert False

test_my.py:17: AssertionError

------------------------------ Captured log call -------------------------------
INFO     test_my:test_my.py:16 Test log 1


------------------------------ Captured log call -------------------------------
INFO     test_my:test_my.py:16 Test log 2

It looks like there is logic in _process_logs to skip rerun logs, but this function is not called (maybe it was changed in pytest).

    # Don't add captured output to reruns
    if report.outcome != "rerun":
@BeyondEvil
Copy link
Contributor

What's the expectation here? 🤔

Shouldn't the final result have all logs? Including those of reruns?

Maybe it looks like it doesn't on a trivial example, but in the real world the logs might contain crucial information to solve flaky logic.

@orgads
Copy link
Author

orgads commented Jan 7, 2024

From my point of view, only the logs of the last (re)run matter.

@BeyondEvil
Copy link
Contributor

BeyondEvil commented Jan 7, 2024

Ok, maybe that makes sense if the logs for previous runs are available in those runs in the report.

Can you clarify what you mean when you say that "_process_logs" isn't called?

@orgads

@orgads
Copy link
Author

orgads commented Jan 7, 2024

I didn't say it isn't called, maybe it's called earlier, or maybe not in the right context, or maybe I misunderstood its purpose :)

@BeyondEvil
Copy link
Contributor

heh, ok.

I'll explore the behaviour in 3.x and compare.

@jeffwright13
Copy link
Collaborator

From my point of view, only the logs of the last (re)run matter.

I would think the exact opposite, myself. Why don't you care seeing logs from previous failures that force a rerun? Those test cases are the most flaky, and therefore of the most interest.

@orgads
Copy link
Author

orgads commented Jan 8, 2024

Right, but if it failed 3 times, and each run produces many logs, having the logs duplicated is cumbersome. I assume that if all runs failed, then the last run shouldn't be much different than the previous ones.

@jeffwright13
Copy link
Collaborator

We're running a plugin called pytest-rerunfailures. We might expect to see output from reruns :-)

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

3 participants