mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-01-23 10:15:11 +00:00
Make it easier to read assert_output failure by showing mismatched line rather than just mismatched length. Also, .format can't evaluate arbitrary Python
This commit is contained in:
parent
93edf6fced
commit
d29cd6f464
1 changed files with 7 additions and 6 deletions
|
|
@ -226,11 +226,7 @@ class OutputFailure(Exception):
|
|||
|
||||
def assert_output(output, expected_entries, prefix=None):
|
||||
lines = tuple(filter(None, output.split('\n')))
|
||||
if len(lines) != len(expected_entries):
|
||||
raise OutputFailure(
|
||||
'Output has {len(lines)} lines, while we expect '
|
||||
'{len(expected_entries)} lines.'.format(**locals())
|
||||
)
|
||||
|
||||
if prefix is not None:
|
||||
for line in lines:
|
||||
if not line.startswith(prefix):
|
||||
|
|
@ -240,4 +236,9 @@ def assert_output(output, expected_entries, prefix=None):
|
|||
if not expected_entry.check(line):
|
||||
raise OutputFailure(line)
|
||||
|
||||
|
||||
if len(lines) != len(expected_entries):
|
||||
raise OutputFailure(
|
||||
'Output has {} lines, while we expect '
|
||||
'{} lines.'.format(
|
||||
len(lines), len(expected_entries))
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue