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

compatibility with insert_assert #10

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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