Skip to content

Commit 401794e

Browse files
committed
Fix bug where lenient_diff will hang indefinitely
1 parent 316177d commit 401794e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dragon_runner/runner.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,11 @@ def lenient_diff(produced: bytes, expected: bytes, pattern: str) -> str:
357357
Perform a lenient diff on error messages, using the pattern as a mask/filter.
358358
Unfortunately we have to convert from and back to bytes in order to apply regex.
359359
Bytes must be UTF-8 decodable.
360-
"""
361-
produced_str = p.strip() if (p := bytes_to_str(produced)) else None
360+
"""
361+
produced_first_line = produced.split(b'\n', 1)[0]
362+
produced_str = p.strip() if (p := bytes_to_str(produced_first_line)) else None
362363
expected_str = e.strip() if (e := bytes_to_str(expected)) else None
363-
364+
364365
if not produced_str or not expected_str:
365366
return "Failed to decode error bytes"
366367

0 commit comments

Comments
 (0)