pytest-dev / pytest-dev/pytest-html
Logs before rerun appear in html report
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 779
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
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":
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating _process_logs and the pytest report-processing hook used by the HTML plugin, then reproduce the issue with the provided test and pytest --reruns 1 --html=report.html. Done means the generated report contains logs from only the relevant test attempt rather than both runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100