Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add str() support to LineMatcher #8050

Merged
merged 8 commits into from
Nov 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/1265.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added __str__ method to LineMatcher class.
mcsitter marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 5 additions & 1 deletion src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,10 @@ def __init__(self, lines: List[str]) -> None:
self.lines = lines
self._log_output: List[str] = []

def __str__(self) -> str:
"""Return the entire original text."""
mcsitter marked this conversation as resolved.
Show resolved Hide resolved
return "\n".join(self.lines)

def _getlines(self, lines2: Union[str, Sequence[str], Source]) -> Sequence[str]:
if isinstance(lines2, str):
lines2 = Source(lines2)
Expand Down Expand Up @@ -1908,4 +1912,4 @@ def _fail(self, msg: str) -> None:

def str(self) -> str:
"""Return the entire original text."""
return "\n".join(self.lines)
return self.__str__()
mcsitter marked this conversation as resolved.
Show resolved Hide resolved