Created
April 27, 2015 18:32
-
-
Save astraw38/666938cadd643ed5f22b to your computer and use it in GitHub Desktop.
in pytest_runtest_makereport() in pytest_plugin.py:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if rep.failed: | |
if hasattr(rep.longrepr, "sections"): | |
local_vars = call.excinfo.traceback[-1].locals | |
longest_name = max([len(str(item)) for item in local_vars.keys()]) | |
local_list = [] | |
for item, value in local_vars.items(): | |
if str(value) not in repr(value): | |
single_local_str = "{:%s} = " % longest_name | |
single_local_str = single_local_str.format(item) | |
single_local_str += " {}".format(str(value).strip()) | |
local_list.append(single_local_str) | |
local_str = "\n".join(local_list) | |
rep.longrepr.sections.append(("str(Locals)", local_str, '-')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment