Skip to content
Open
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
15 changes: 15 additions & 0 deletions nbval/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ def compare_outputs(self, test, ref, skip_compare=None):
cc.FAIL
+ "Unexpected output fields from running code: %s"
% (test_keys - ref_keys)
+ self.maybe_show_output_mismatch(testing_outs,
reference_outs)
+ cc.ENDC
)
return False
Expand Down Expand Up @@ -520,6 +522,19 @@ def compare_outputs(self, test, ref, skip_compare=None):
return False
return True

def maybe_show_output_mismatch(self, testing_outs, reference_outs,
verbosity_for_show=3):
"""Show testing outputs not in reference outputs based on verbosity.
"""
if self.config.get_verbosity() >= verbosity_for_show:
result = []
for stream, contents in testing_outs.items():
if stream not in reference_outs:
result.append(
f'\n{stream} in test but not in reference: {contents}\n')
return '\n'.join(result)
return ''

def format_output_compare(self, key, left, right):
"""Format an output for printing"""
if isinstance(left, str):
Expand Down