Skip to content

Commit

Permalink
compatibility with insert_assert (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin authored Apr 5, 2023
1 parent 04de13d commit 53cf8d7
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions pytest_pretty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,25 @@ def pytest_sessionfinish(session, exitstatus):
class CustomTerminalReporter(TerminalReporter):
def pytest_runtest_logreport(self, report: TestReport) -> None:
super().pytest_runtest_logreport(report)
if report.failed:
file, line, func = report.location
self._write_progress_information_filling_space()
self.ensure_newline()
summary = f'{file}:{line} {func}'
self._tw.write(summary, red=True)
try:
msg = report.longrepr.reprcrash.message
except AttributeError:
pass
else:
msg = msg.replace('\n', ' ')
available_space = self._tw.fullwidth - len(summary) - 15
if available_space > 5:
self._tw.write(f' - {msg[:available_space]}…')
if not report.failed:
return None
if report.when == 'teardown' and 'devtools-insert-assert:' in repr(report.longrepr):
# special case for devtools insert_assert "failures"
return None
file, line, func = report.location
self._write_progress_information_filling_space()
self.ensure_newline()
summary = f'{file}:{line} {func}'
self._tw.write(summary, red=True)
try:
msg = report.longrepr.reprcrash.message
except AttributeError:
pass
else:
msg = msg.replace('\n', ' ')
available_space = self._tw.fullwidth - len(summary) - 15
if available_space > 5:
self._tw.write(f' - {msg[:available_space]}…')

def summary_stats(self) -> None:
time_taken_ns = end_time - start_time
Expand Down Expand Up @@ -148,9 +152,9 @@ class PytesterWrapper:
def __init__(self, pytester):
object.__setattr__(self, '_pytester', pytester)

def runpytest(self):
def runpytest(self, *args, **kwargs):
"""wraper to overwritte `parseoutcomes` method of `RunResult` instance"""
res = self._pytester.runpytest()
res = self._pytester.runpytest(*args, **kwargs)
assert res is not None
res.parseoutcomes = create_new_parseoutcomes(res)
return res
Expand Down

0 comments on commit 53cf8d7

Please sign in to comment.