Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreldm committed Sep 10, 2024
1 parent 3e9f7ca commit 183ea20
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,13 @@ def flush(self) -> None:
def write_line(self, line: str | bytes, **markup: bool) -> None:
if not isinstance(line, str):
line = str(line, errors="replace")

if self._all_tests_finished and self._first_write_after_tests:
self._first_write_after_tests = False
self.currentfspath = None
else:
self.ensure_newline()

self._tw.line(line, **markup)

def rewrite(self, line: str, **markup: bool) -> None:
Expand Down Expand Up @@ -594,9 +596,8 @@ def pytest_runtest_logstart(
self.flush()

def pytest_runtest_logreport(self, report: TestReport) -> None:
if report.when == "teardown":
if report.when == 'teardown':
self._all_tests_finished = True
self._tests_ran = True
rep = report

res = TestShortLogReport(
Expand Down Expand Up @@ -625,7 +626,6 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
markup = {}
self._progress_nodeids_reported.add(rep.nodeid)
if self.config.get_verbosity(Config.VERBOSITY_TEST_CASES) <= 0:
self.ensure_newline()
self._tw.write(letter, **markup)
# When running in xdist, the logreport and logfinish of multiple
# items are interspersed, e.g. `logreport`, `logreport`,
Expand Down Expand Up @@ -658,7 +658,6 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
self.wrap_write(formatted_reason)
if self._show_progress_info:
self._write_progress_information_filling_space()
self.currentfspath = None
else:
self.ensure_newline()
self._tw.write(f"[{rep.node.gateway.id}]")
Expand Down Expand Up @@ -899,7 +898,7 @@ def _printcollecteditems(self, items: Sequence[Item]) -> None:
@hookimpl(wrapper=True)
def pytest_sessionfinish(
self, session: Session, exitstatus: int | ExitCode
) -> Generator[None]:
) -> Generator[None, None, None]:
result = yield
self._tw.line("")
summary_exit_codes = (
Expand All @@ -924,7 +923,7 @@ def pytest_sessionfinish(
return result

@hookimpl(wrapper=True)
def pytest_terminal_summary(self) -> Generator[None]:
def pytest_terminal_summary(self) -> Generator[None, None, None]:
self.summary_errors()
self.summary_failures()
self.summary_xfailures()
Expand Down Expand Up @@ -1586,4 +1585,4 @@ def _get_raw_skip_reason(report: TestReport) -> str:
reason = reason[len("Skipped: ") :]
elif reason == "Skipped":
reason = ""
return reason
return reason

0 comments on commit 183ea20

Please sign in to comment.