MCPcopy Create free account
hub / github.com/pytest-dev/pytest / assert_contains_lines

Method assert_contains_lines

src/_pytest/pytester.py:1512–1522  ·  view source on GitHub ↗

Assert that ``lines2`` are contained (linearly) in :attr:`stringio`'s value. Lines are matched using :func:`LineMatcher.fnmatch_lines `.

(self, lines2: Sequence[str])

Source from the content-addressed store, hash-verified

1510 """:class:`python:io.StringIO()` instance used for input."""
1511
1512 def assert_contains_lines(self, lines2: Sequence[str]) -> None:
1513 """Assert that ``lines2`` are contained (linearly) in :attr:`stringio`'s value.
1514
1515 Lines are matched using :func:`LineMatcher.fnmatch_lines <pytest.LineMatcher.fnmatch_lines>`.
1516 """
1517 __tracebackhide__ = True
1518 val = self.stringio.getvalue()
1519 self.stringio.truncate(0)
1520 self.stringio.seek(0)
1521 lines1 = val.split("\n")
1522 LineMatcher(lines1).fnmatch_lines(lines2)
1523
1524
1525class LineMatcher:

Callers 2

test_internalerrorMethod · 0.80

Calls 3

LineMatcherClass · 0.85
fnmatch_linesMethod · 0.80
getvalueMethod · 0.45

Tested by

no test coverage detected