pytest-dev / pytest-dev/pytest
terminalreporter prepends a newline on first write if tests are collected
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
# conftest.py
def pytest_terminal_summary(terminalreporter):
terminalreporter.section("This is a section.")
terminalreporter.write_line("This is a line.")
terminalreporter.write_line("This is another line.")
terminalreporter.section("This is another section.")
terminalreporter.write_line("This is a 3rd line.")
terminalreporter.write_line("This is a 4th line.")
$ pipenv run pytest
====================== test session starts =======================
platform linux -- Python 3.10.12, pytest-8.3.2, pluggy-1.5.0
rootdir: /tmp/tmp.WXMdPn0b6L
collected 0 items
======================= This is a section. =======================
This is a line.
This is another line.
==================== This is another section. ====================
This is a 3rd line.
This is a 4th line.
===================== no tests ran in 0.00s ======================
$ pipenv run pytest
====================== test session starts =======================
platform linux -- Python 3.10.12, pytest-8.3.2, pluggy-1.5.0
rootdir: /tmp/tmp.WXMdPn0b6L
collected 1 item
test_pass.py . [100%]
======================= This is a section. =======================
<------ Where did this come from?
This is a line.
This is another line.
==================== This is another section. ====================
This is a 3rd line.
This is a 4th line.
======================= 1 passed in 0.00s ========================
Contributor guide
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
Reproduce the behavior using the provided conftest.py and terminalreporter.section/write_line calls, once with no tests and once with a collected test. Trace the terminal reporter's first write and compare the output around the section header; done means the extra leading newline is absent while the reported sections and lines remain correctly formatted.
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
- 45/100