MCPcopy
hub / github.com/pytest-dev/pytest / assert_contains_lines

Method assert_contains_lines

src/_pytest/pytester.py:1559–1569  ·  view source on GitHub ↗

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

(self, lines2: Sequence[str])

Source from the content-addressed store, hash-verified

1557 """:class:`python:io.StringIO()` instance used for input."""
1558
1559 def assert_contains_lines(self, lines2: Sequence[str]) -> None:
1560 """Assert that ``lines2`` are contained (linearly) in :attr:`stringio`&#x27;s value.
1561
1562 Lines are matched using :func:`LineMatcher.fnmatch_lines <pytest.LineMatcher.fnmatch_lines>`.
1563 """
1564 __tracebackhide__ = True
1565 val = self.stringio.getvalue()
1566 self.stringio.truncate(0)
1567 self.stringio.seek(0)
1568 lines1 = val.split("\n")
1569 LineMatcher(lines1).fnmatch_lines(lines2)
1570
1571
1572class LineMatcher:

Callers 2

test_internalerrorMethod · 0.80

Calls 5

LineMatcherClass · 0.85
truncateMethod · 0.80
seekMethod · 0.80
fnmatch_linesMethod · 0.80
getvalueMethod · 0.45

Tested by

no test coverage detected