From 4021770688c3781355766af4fc501e8378b0c6d7 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 19 Feb 2020 13:16:57 +0100 Subject: [PATCH] pytester: LineMatcher: use `_fail` with `_match_lines_random` (#6747) --- src/_pytest/pytester.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index b69bfd5bc..3c87387eb 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1354,8 +1354,9 @@ class LineMatcher: self._log("matched: ", repr(line)) break else: - self._log("line %r not found in output" % line) - raise ValueError(self._log_text) + msg = "line %r not found in output" % line + self._log(msg) + self._fail(msg) def get_lines_after(self, fnline: str) -> Sequence[str]: """Return all lines following the given line in the text.