From b0a7719bf1520f08ba0d66a50e76e54b68209eca Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 9 May 2022 07:50:58 +0200 Subject: [PATCH] Add a __repr__ method to Document --- earthsnake/document/__init__.py | 3 +++ tests/test_document_es4.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/earthsnake/document/__init__.py b/earthsnake/document/__init__.py index a135646..88bb6e4 100644 --- a/earthsnake/document/__init__.py +++ b/earthsnake/document/__init__.py @@ -30,3 +30,6 @@ class Document(ABC): # pragma: no cover pylint: disable=too-few-public-methods If ``identity`` is ``None``, use ``self.author`` instead. """ + + def __repr__(self) -> str: + return f'<{self.__class__.__name__} {self.path} by {self.author}>' diff --git a/tests/test_document_es4.py b/tests/test_document_es4.py index 6532cb9..2faeced 100644 --- a/tests/test_document_es4.py +++ b/tests/test_document_es4.py @@ -257,3 +257,12 @@ def test_content_length(es4_document: Es4Document) -> None: """Test the content_length property""" assert es4_document.content_length == 4 + + +def test_repr(es4_document: Es4Document) -> None: + """Test the __repr__ method of Es4Document""" + + assert ( + repr(es4_document) + == '' + )