From 5e57b24200d0883b0bf6f40e56192ba10efec2df Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Thu, 5 May 2022 13:38:53 +0200 Subject: [PATCH] Add a __str__ and __repr__ method to Path --- earthsnake/path.py | 6 ++++++ tests/test_path.py | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/earthsnake/path.py b/earthsnake/path.py index d01236c..d39c5ab 100644 --- a/earthsnake/path.py +++ b/earthsnake/path.py @@ -69,3 +69,9 @@ class Path: return True return False + + def __str__(self) -> str: + return self.path + + def __repr__(self) -> str: + return f'' diff --git a/tests/test_path.py b/tests/test_path.py index 20ed47b..d3c87f8 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -94,3 +94,15 @@ def test_can_write(author: str, path: str, allowed: bool) -> None: identity = Identity.from_address(author) assert path_obj.can_write(identity) is allowed + + +def test_str() -> None: + """Test the __str__ method""" + + assert str(Path('/test.txt')) == '/test.txt' + + +def test_repr() -> None: + """Test the __repr__ method""" + + assert repr(Path('/test.txt')) == ''