Add startswith() and endswith() methods to Path

This commit is contained in:
2022-05-06 17:20:59 +02:00
parent 1299acd463
commit b9d0221e95
2 changed files with 28 additions and 0 deletions

View File

@@ -106,3 +106,21 @@ def test_repr() -> None:
"""Test the __repr__ method"""
assert repr(Path('/test.txt')) == '<Path /test.txt>'
def test_startswith() -> None:
"""Test the startswith method"""
path = Path('/test.txt')
assert path.startswith('/test')
assert not path.startswith('test')
def test_endswith() -> None:
"""Test the endswith method"""
path = Path('/test.txt')
assert path.endswith('.txt')
assert not path.endswith('.py')