mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Using relative path for shorter repr.
This commit is contained in:
parent
bedcc3a5e9
commit
3284a210bf
2 changed files with 6 additions and 1 deletions
|
|
@ -18,7 +18,7 @@ class MediaPath:
|
|||
self._path = path.absolute()
|
||||
|
||||
def __repr__(self):
|
||||
return f'<MediaPath path={self.path}>'
|
||||
return f'<MediaPath path={self.path.relative_to(get_media_directory())}>'
|
||||
|
||||
@classmethod
|
||||
def _validate_path(cls, path: PATH_TYPE):
|
||||
|
|
|
|||
|
|
@ -43,3 +43,8 @@ class TestMediaPath(unittest.TestCase):
|
|||
|
||||
# Error is raised when the path is not in the media path.
|
||||
self.assertRaises(ValueError, MediaPath, '/tmp/foo')
|
||||
|
||||
def test_repr(self):
|
||||
d = MediaPath('foo')
|
||||
assert self.test_dir.name not in repr(d)
|
||||
assert self.test_dir.name not in str(d)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue