Skip to content

Commit

Permalink
Fixes according to reviewer's remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Alexeev committed Mar 11, 2021
1 parent b70d6cf commit 7c3eb70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/170.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Add pretty string representation for matchers objects
5 changes: 3 additions & 2 deletions src/hamcrest/core/string_description.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from hamcrest.core.selfdescribing import SelfDescribing
from textwrap import shorten

from .base_description import BaseDescription

Expand Down Expand Up @@ -32,8 +33,8 @@ def __str__(self) -> str:
return self.out

def __repr__(self) -> str:

This comment has been minimized.

Copy link
@brunns

brunns Mar 11, 2021

Member

I think this __repr__() method would need to be on the BaseMatcher class rather than on StringDescription.

"""Returns the description."""
return self.out
"""Returns the object string representation."""
return "<{0}({1})>".format(self.__class__.__name__, shorten(self.out, 60, placeholder="..."))

def append(self, string: str) -> None:
self.out += str(string)

0 comments on commit 7c3eb70

Please sign in to comment.