From 792d641ff9cab3fa544e20a6449310cdef76bccf Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Fri, 12 Apr 2019 11:12:19 -0700 Subject: [PATCH] Fix escape sequence in docstring --- rbackup/struct/hierarchy.py | 4 +++- tests/test_hierarchy.py | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/rbackup/struct/hierarchy.py b/rbackup/struct/hierarchy.py index f3f4f8c..e806b2a 100644 --- a/rbackup/struct/hierarchy.py +++ b/rbackup/struct/hierarchy.py @@ -25,6 +25,8 @@ class Hierarchy(PathLike): to call either shutil.mkdir() or a related method to create the directory structure it emulates. + For consistency, Hierarchy objects always store and return absolute paths. + Attributes ---------- * Hierarchy.path @@ -49,7 +51,7 @@ class Hierarchy(PathLike): :type dest: str or path-like object """ try: - self._path = Path(dest) + self._path = Path(dest).resolve() except TypeError as e: raise e diff --git a/tests/test_hierarchy.py b/tests/test_hierarchy.py index 36c6de1..c061b30 100644 --- a/tests/test_hierarchy.py +++ b/tests/test_hierarchy.py @@ -9,7 +9,7 @@ from pathlib import Path from unittest.mock import PropertyMock, patch from hypothesis import given -from hypothesis.strategies import characters, one_of, text +from hypothesis.strategies import from_regex, text from rbackup.struct.hierarchy import Hierarchy @@ -20,9 +20,9 @@ TESTING_MODULE = f"{TESTING_PACKAGE}.hierarchy" # ========== Tests ========== class TestHierarchyPaths(unittest.TestCase): - @given(one_of(text(), characters())) - def test_returns_correct_path(self, p): - self.assertEqual(Path(p), Hierarchy(p).path) + @given(from_regex(r"[\w/._-]+", fullmatch=True)) + def test_returns_absolute_path(self, dest): + self.assertTrue(Hierarchy(dest).path.is_absolute()) def test_raises_notimplemented_error(self): h = Hierarchy("backup")