Add a __repr__ method to Document

This commit is contained in:
Gergely Polonkai 2022-05-09 07:50:58 +02:00
parent ae99aba0e0
commit b0a7719bf1
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
2 changed files with 12 additions and 0 deletions

View File

@ -30,3 +30,6 @@ class Document(ABC): # pragma: no cover pylint: disable=too-few-public-methods
If ``identity`` is ``None``, use ``self.author`` instead. If ``identity`` is ``None``, use ``self.author`` instead.
""" """
def __repr__(self) -> str:
return f'<{self.__class__.__name__} {self.path} by {self.author}>'

View File

@ -257,3 +257,12 @@ def test_content_length(es4_document: Es4Document) -> None:
"""Test the content_length property""" """Test the content_length property"""
assert es4_document.content_length == 4 assert es4_document.content_length == 4
def test_repr(es4_document: Es4Document) -> None:
"""Test the __repr__ method of Es4Document"""
assert (
repr(es4_document)
== '<Es4Document /test.txt by @test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya>'
)